Set up is Windows 7 / Office 2007. Access code is automating Word.
The following code (which deletes page 2) works on most PCs
However I have one PC where the first line does not go to the page.
I have found a workaround of using the Selection object like this (where objWord is the main Word Application object)
I have also tried http://word.mvps.org/faqs/macrosvba/SelectCurPage.htm a few variations such as what is suggested here.
Can anyone help me to understand why I cannot do this from the Document (ActiveDocument) but I can from the Selection.
Also why does it work on some PCs and not on others.
The following code (which deletes page 2) works on most PCs
Code:
With objWord.ActiveDocument
Set rng = .GoTo(What:=wdGoToPage, name:="2")
Set rng = rng.GoTo(What:=wdGoToBookmark, name:="\page")
rng.Delete
Set rng = Nothing
End With
Code:
.GoTo(What:=wdGoToPage, name:="2")
Code:
Set rng = objWord.Selection.GoTo(What:=wdGoToPage, name:="2")
Can anyone help me to understand why I cannot do this from the Document (ActiveDocument) but I can from the Selection.
Also why does it work on some PCs and not on others.