首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VBA >

word插入页码出错!解决方法

2013-01-27 
word插入页码出错!Dim WordApp As Word.Application -避免使用 As New 定义Dim NewDoc As Word.Document

word插入页码出错!
Dim WordApp As Word.Application '<-避免使用 As New 定义
  Dim NewDoc As Word.Document '<-要显示定义局部变量
  Set WordApp = New Word.Application
  Set NewDoc = WordApp.Documents.Add
  WordApp.Visible = True
  'WordApp.WordBasic.ToggleDocumentText
  WordApp.WordBasic.ViewFooterOnly
  WordApp.ActiveDocument.AttachedTemplate.BuildingBlockEntries("普通数字 2").Insert Where:=WordApp.Selection.Range, RichText:=True
    
  WordApp.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

我用上述代码调用word插入页码时提示“实时错误5941 ,集合要求的成员不存在”
求问大家,这个是那个成员有问题,查了半天都没找到,该怎么改一下啊,谢谢大家帮忙啦先!
[解决办法]
怀疑“("普通数字 2").”不能用吧,用index行不?
[解决办法]

引用:
怀疑“("普通数字 2").”不能用吧,用index行不?

这是录制宏后形成的。
[解决办法]
WordApp.ActiveDocument.AttachedTemplate.BuildingBlockEntries("普通数字 2").Insert Where:=WordApp.Selection.Range, RichText:=True

这里的{BuildingBlockEntries("普通数字 2").Insert}不对,不能这么用.
[解决办法]
引用:
WordApp.ActiveDocument.AttachedTemplate.BuildingBlockEntries("普通数字 2").Insert Where:=WordApp.Selection.Range, RichText:=True

这里的{BuildingBlockEntries("普通数字 2").Insert}不对,不能这么用.

求问:该怎么用?

热点排行