M
Me
I previously posted this to the Microsoft Communities:
_____________________
When I open a previously saved file and cancel options to enter a new number
and form name, a debugging error message comes up (Run-time error ‘4605’).
When the "end" option within that dialog box is selected, my cursor is placed
within the header instead of in the document, and when I close out of the
header/footer toolbar, I’m taken back to the document, but the entire
document is selected instead of me simply being within a certain cell or row.
This debugging error does not happen when the form is being created as
normal; this is only an issue when previously saved forms are opened to be
edited.
When the "debug" option within that dialog box is selected, I am taken into
the Visual Basic editor and show the following macro:
* * * * * *
Sub AutoOpen()
Selection.HomeKey Unit:=wdStory
Selection.WholeStory
Selection.Fields.Update
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Or
ActiveWindow.ActivePane.View.Type _
= wdMasterView Then
ActiveWindow.ActivePane.View.Type = wdPageView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveWindow.ActivePane.View.NextHeaderFooter
Selection.WholeStory
Selection.Fields.Update
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.HomeKey Unit:=wdStory
End Sub
* * * * * *
The macro bombs out at “ActiveWindow.ActivePane.View.NextHeaderFooter.â€
________________________________
The answer I received was to change the coding to this:
Sub AutoOpen()
Selection.HomeKey Unit:=wdStory
Selection.WholeStory
Selection.Fields.Update
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Or
ActiveWindow.ActivePane.View.Type _
= wdMasterView Then
ActiveWindow.ActivePane.View.Type = wdPageView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
On Error resume next
ActiveWindow.ActivePane.View.NextHeaderFooter
If err.number = 0 then
on error goto 0
Selection.WholeStory
Selection.Fields.Update
End iF
on error goto 0
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.HomeKey Unit:=wdStory
End Sub
I did this, however, the new code works fine when functioning only with
Word, but when the code tries to execute via an Access macro, we receive a
“Compile error: Syntax error†message. I believe the line
“ActiveWindow.ActivePane.View.NextHeaderFooter†generates this message.
This Word macro runs via a macro initialized by a “button†inside an Access
file. The Access macro is responsible for opening the Word document that
will be utilized. The Word document is not opened prior to running the
Access macro.
Any help would be greatly appreciated.
_____________________
When I open a previously saved file and cancel options to enter a new number
and form name, a debugging error message comes up (Run-time error ‘4605’).
When the "end" option within that dialog box is selected, my cursor is placed
within the header instead of in the document, and when I close out of the
header/footer toolbar, I’m taken back to the document, but the entire
document is selected instead of me simply being within a certain cell or row.
This debugging error does not happen when the form is being created as
normal; this is only an issue when previously saved forms are opened to be
edited.
When the "debug" option within that dialog box is selected, I am taken into
the Visual Basic editor and show the following macro:
* * * * * *
Sub AutoOpen()
Selection.HomeKey Unit:=wdStory
Selection.WholeStory
Selection.Fields.Update
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Or
ActiveWindow.ActivePane.View.Type _
= wdMasterView Then
ActiveWindow.ActivePane.View.Type = wdPageView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveWindow.ActivePane.View.NextHeaderFooter
Selection.WholeStory
Selection.Fields.Update
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.HomeKey Unit:=wdStory
End Sub
* * * * * *
The macro bombs out at “ActiveWindow.ActivePane.View.NextHeaderFooter.â€
________________________________
The answer I received was to change the coding to this:
Sub AutoOpen()
Selection.HomeKey Unit:=wdStory
Selection.WholeStory
Selection.Fields.Update
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Or
ActiveWindow.ActivePane.View.Type _
= wdMasterView Then
ActiveWindow.ActivePane.View.Type = wdPageView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
On Error resume next
ActiveWindow.ActivePane.View.NextHeaderFooter
If err.number = 0 then
on error goto 0
Selection.WholeStory
Selection.Fields.Update
End iF
on error goto 0
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.HomeKey Unit:=wdStory
End Sub
I did this, however, the new code works fine when functioning only with
Word, but when the code tries to execute via an Access macro, we receive a
“Compile error: Syntax error†message. I believe the line
“ActiveWindow.ActivePane.View.NextHeaderFooter†generates this message.
This Word macro runs via a macro initialized by a “button†inside an Access
file. The Access macro is responsible for opening the Word document that
will be utilized. The Word document is not opened prior to running the
Access macro.
Any help would be greatly appreciated.