dro^
07-24-2012, 06:51 AM
Morning Folks,
Nice looking forums lurked around a bit but couldn't find my solution. I am currently creating a macro to drop in the header and footer from 3 files ( header file, footer1, and footer2 ) just because it makes it easier to edit the text on the server once.
The problem: if there is only one page then Active window does not see "wdSeekPrimaryFooter" returns an error and stops the macro. I need the macro to either possibly activate the field so that when a 2nd page does become present the 2nd footer is properly displayed or some other means I know there is a million different ways to do things with code. Any help with this or any tips on how this is written or could be improved I greatly appreciate trying to get a hang of this. -dro^
Error code: :beerchug:
'2nd page footer "CurrentPageFooter"
ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryFooter
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertFile FileName:="N:\cpwin\macro\vbfoot2.dotx", Link:=False
Full code:
Sub LHMacroTemp()
'Sets multiheader enviroment
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
With ActiveDocument.Sections(1)
.PageSetup.DifferentFirstPageHeaderFooter = True
End With
'2nd page footer "CurrentPageFooter"
ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryFooter
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertFile FileName:="N:\cpwin\macro\vbfoot2.dotx", Link:=False
'Set FirstPageFooter
ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageFooter
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertFile FileName:="N:\cpwin\macro\vbfoot1.docx", Link:=False
'Set FirstPageHeader
ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageHeader
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertFile FileName:="N:\cpwin\macro\vbhead.dotm", Link:=False
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
End Sub
Nice looking forums lurked around a bit but couldn't find my solution. I am currently creating a macro to drop in the header and footer from 3 files ( header file, footer1, and footer2 ) just because it makes it easier to edit the text on the server once.
The problem: if there is only one page then Active window does not see "wdSeekPrimaryFooter" returns an error and stops the macro. I need the macro to either possibly activate the field so that when a 2nd page does become present the 2nd footer is properly displayed or some other means I know there is a million different ways to do things with code. Any help with this or any tips on how this is written or could be improved I greatly appreciate trying to get a hang of this. -dro^
Error code: :beerchug:
'2nd page footer "CurrentPageFooter"
ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryFooter
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertFile FileName:="N:\cpwin\macro\vbfoot2.dotx", Link:=False
Full code:
Sub LHMacroTemp()
'Sets multiheader enviroment
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
With ActiveDocument.Sections(1)
.PageSetup.DifferentFirstPageHeaderFooter = True
End With
'2nd page footer "CurrentPageFooter"
ActiveWindow.ActivePane.View.SeekView = wdSeekPrimaryFooter
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertFile FileName:="N:\cpwin\macro\vbfoot2.dotx", Link:=False
'Set FirstPageFooter
ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageFooter
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertFile FileName:="N:\cpwin\macro\vbfoot1.docx", Link:=False
'Set FirstPageHeader
ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageHeader
Selection.Collapse Direction:=wdCollapseEnd
Selection.InsertFile FileName:="N:\cpwin\macro\vbhead.dotm", Link:=False
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
End Sub