|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
怪事:下列代码,在录制宏后,接着运行,没有错误,但关闭文档再运行代码时,却弹出“运行时错误‘5941’集合所要求的成员不存在”对话框,不知何故。
代码如下:
Sub 插入页脚出问题()
With ActiveWindow.ActivePane.View
.SeekView = wdSeekCurrentPageFooter
Application.Templates("C:\Users\Administrator\AppData\Roaming\Microsoft\Document Building Blocks\2052\14\Built-In Building Blocks.dotx").BuildingBlockEntries("普通数字 3").Insert Where:=Selection.Range
With Selection
.MoveUp Unit:=wdParagraph, Count:=1
.InsertBefore "第"
.MoveRight Unit:=wdCharacter, Count:=2
.TypeText Text:="页(共"
.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="NUMPAGES ", PreserveFormatting:=True
.MoveUp Unit:=wdParagraph, Count:=1
.MoveRight Unit:=wdCharacter, Count:=Selection.Paragraphs(1).Range.Characters.Count - 1
.InsertBefore "页)"
.Paragraphs(1).Range.Select
.ParagraphFormat.Alignment = wdAlignParagraphRight
.Font.Name = "楷体"
.Font.Name = "Arial Narrow"
End With
End With
End Sub
|
|