在Word中创建宏 [英] Creating Macro in Word
问题描述
我正在尝试创建一个宏,将我的名称左对齐,日期居中,标题右对齐,并在页脚中居中页码。我记录了宏,然后运行它,但我收到错误,上面写着"运行时间错误5941"
收集的请求成员不存在。我不知道如何解决它。我粘贴了下面的代码。你能帮我吗我明天需要它吗
Macro2 Macro
'
'
如果ActiveWindow.View.SplitSpecial<> wdPaneNone然后
&NBSP; &NBSP; ActiveWindow.Panes(2)。关闭
结束如果
如果ActiveWindow.ActivePane.View.Type = wdNormalView或ActiveWindow。 _
&NBSP; &NBSP; ActivePane.View.Type = wdOutlineView然后
&NBSP; &NBSP; ActiveWindow.ActivePane.View.Type = wdPrintView
结束如果
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveDocument.AttachedTemplate.BuildingBlockEntries(_
" Blank(Three Columns)")。Insert Where:= Selection.Range,RichText :=真
Selection.MoveRight Unit:= wdCharacter,Count:= 1
Selection.Delete Unit:= wdCharacter,Count:= 1
Selection.TypeText Text:=" Tina"
Selection.MoveRight Unit:= wdCharacter,Count:= 2
Selection.Delete Unit:= wdCharacter,Count:= 1
Selection.InsertDateTime DateTimeFormat:=" MMMM d,yyyy",InsertAsField:= _
&NBSP; &NBSP; False,DateLanguage:= wdEnglishUS,CalendarType:= wdCalendarWestern,_
&NBSP; &NBSP; InsertAsFullWidth:= False
Selection.MoveRight Unit:= wdCharacter,Count:= 2
Selection.Delete Unit:= wdCharacter,Count:= 1
Selection.TypeText Text:=" Microsoft Word"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
WordBasic.ViewFooterOnly
ActiveDocument.AttachedTemplate.BuildingBlockEntries(" Blank")。插入_
&NBSP; &NBSP; 其中:= Selection.Range,RichText:= True
Selection.TypeText Text:= vbTab
WordBasic.ViewFooterOnly
ActiveDocument.AttachedTemplate.BuildingBlockEntries(" Plain Number 2")。 _
&NBSP; &NBSP; 插入位置:= Selection.Range,RichText:= True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
看起来像是VBA论坛的一个问题:
http://social.msdn.microsoft.com/Forums/en-US/isvvba/threads
I am trying to create a macro that inserts my name left aligned, date centered, title right aligned and in the footer the page number centered. I recorded the macro then run it but I get the error that says "RUN TIME ERROR 5941 THE REQUEST MEMBER OF THE COLLECTION DOES NOT EXIST. I don't know how to fix it. I pasted the code below. Can you please help me I need it by tomorrow
Macro2 Macro
'
'
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveDocument.AttachedTemplate.BuildingBlockEntries( _
" Blank (Three Columns)").Insert Where:=Selection.Range, RichText:=True
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="Tina"
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.InsertDateTime DateTimeFormat:="MMMM d, yyyy", InsertAsField:= _
False, DateLanguage:=wdEnglishUS, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="Microsoft Word"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
WordBasic.ViewFooterOnly
ActiveDocument.AttachedTemplate.BuildingBlockEntries(" Blank").Insert _
Where:=Selection.Range, RichText:=True
Selection.TypeText Text:=vbTab
WordBasic.ViewFooterOnly
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Plain Number 2"). _
Insert Where:=Selection.Range, RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
looks like a question for the VBA Forum:
http://social.msdn.microsoft.com/Forums/en-US/isvvba/threads
这篇关于在Word中创建宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!