Private m_WordServer As Word.Application
' Add the file's footer.
Private Sub ProcessFile(ByVal file_name As String)
Debug.Print file_name
' Open the file.
m_WordServer.Documents.Open FileName:=file_name, _
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False, _
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
' Insert the footer.
If m_WordServer.ActiveWindow.View.SplitSpecial <> _
wdPaneNone Then
m_WordServer.ActiveWindow.Panes(2).Close
End If
If m_WordServer.ActiveWindow.ActivePane.View.Type = _
wdNormalView Or _
m_WordServer.ActiveWindow.ActivePane.View.Type = _
wdOutlineView _
Then
m_WordServer.ActiveWindow.ActivePane.View.Type = _
wdPrintView
End If
m_WordServer.ActiveWindow.ActivePane.View.SeekView = _
wdSeekCurrentPageHeader
If m_WordServer.Selection.HeaderFooter.IsHeader = True _
Then
m_WordServer.ActiveWindow.ActivePane.View.SeekView _
= wdSeekCurrentPageFooter
Else
m_WordServer.ActiveWindow.ActivePane.View.SeekView _
= wdSeekCurrentPageHeader
End If
m_WordServer.Selection.EndKey Unit:=wdStory, _
Extend:=wdExtend
m_WordServer.Selection.TypeText Text:="left" & vbTab & _
file_name & vbTab & "right"
m_WordServer.ActiveWindow.ActivePane.View.SeekView = _
wdSeekMainDocument
' Save and close the file.
m_WordServer.ActiveDocument.Save
m_WordServer.ActiveDocument.Close
End Sub
|