Can't write to Word doc header from an Access Form

S

Sergio Florez M.

I recorded a Macro in Word doc in order to place the code
in an Access form. This code writes some text in the doc
header and it works fine in word but in access it says
something about an invalid object when opening the header.

Dim Objword As Word.Application
Set Objword = New Word.Application
Objword.Visible = True

Objword.Documents.Open
FileName:="C:\PlantillaInicialCorrespondencia.doc", _
ConfirmConversions:=False, ReadOnly:=False,
AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="",
Revert:=False, _
WritePasswordDocument:="",
WritePasswordTemplate:="", Format:= _
wdOpenFormatAuto

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 <-- this is where the error is
lifted

Selection.EndKey Unit:=wdLine
Selection.TypeParagraph
Selection.TypeText Text:="Id: xxxxx"
ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
Selection.TypeParagraph
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top