VBA Word - Error 4605 - This command is not available

S

Silvershot

I have little problem with VBA Word.

I am traying to generate a new document that is going to show me a
summery.
I also want it to show me the date and time when the document was mate
in the Footer.
I used the following code.

ActiveWindow.View.SeekView = wdSeekCurrentPageFooter
Selection.TypeText Text:=vbTab & vbTab & "Gemaakt op: "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldDate
Selection.TypeText Text:=" "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldTime
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

But as soon as he reaches ActiveWindow.View.SeekView =
wdSeekCurrentPageFooter I get the error 4605.

I have tried on error resume next but this doesn't seem to work eether
Does anywhone know what I could try to get past this.
 
G

Greg

It worked for me in a simple test. Maybe you could uses ranges rather
than actually entering the footer and using selections:

Sub Test1()
Dim oRng1 As Range
Dim oRng2 As Range
Dim oRng3 As Range
Set oRng1 = ActiveDocument.StoryRanges(wdPrimaryFooterStory)
Set oRng2 = oRng1.Duplicate
oRng1.Text = vbTab & vbTab & "Gemaakt op: "
oRng2.Collapse wdCollapseEnd
oRng2.Fields.Add oRng2, wdFieldDate
oRng1.InsertAfter Text:=" "
Set oRng3 = oRng1.Duplicate
oRng3.Collapse wdCollapseEnd
oRng3.Fields.Add oRng3, wdFieldTime
End Sub
 

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