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.”
I am not familiar with VB coding, so that’s why I’m asking assistance here.
Any help would be greatly appreciated.
Thanks in advance.
Me
Tony Jollans - 02 Nov 2005 00:45 GMT
Hi Me!
Your problem is caused by the document only having one header and the code
trying to jump to the second header.
I don't know what your Forms are normally like or whether the code is
reasonable in the circumstances but adding an error trap (the outdented
lines below) should give a quick fix to make it run to the end,
.....
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
--
Enjoy,
Tony
> 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').
[quoted text clipped - 42 lines]
>
> I am not familiar with VB coding, so that's why I'm asking assistance
here.
> Any help would be greatly appreciated.
>
> Thanks in advance.
>
> Me
Doug Robbins - Word MVP - 03 Nov 2005 21:49 GMT
Just use
With ActiveDocument
.PrintPreview
.ClosePrintPreview
End With

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> When I open a previously saved file and cancel options to enter a new
> number
[quoted text clipped - 53 lines]
>
> Me