Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2005

Tip: Looking for answers? Try searching our database.

Run-time error '4605'

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Me - 14 Jul 2005 17:43 GMT
I recently inherited a Word file at work and I'm getting this error on an
auto run macro.  Since I don't know anything about VB programming, I was
wondering if somewone could tell me how to fix this problem.  This error
prevents me from using this file.

The code is:

* * * *
Sub AutoNew()

   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
* * * *

Can anybody help me with this?

Thanks.
Doug Robbins - 14 Jul 2005 18:34 GMT
If you click on Debug when the error occurs, what line of code is
highlighted.

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

>I recently inherited a Word file at work and I'm getting this error on an
> auto run macro.  Since I don't know anything about VB programming, I was
[quoted text clipped - 35 lines]
>
> Thanks.
Me - 14 Jul 2005 18:42 GMT
D'oh!  That certainly would help wouldn't it.  ;-)

ActiveWindow.ActivePane.View.NextHeaderFooter

Thanks!

> If you click on Debug when the error occurs, what line of code is
> highlighted.
[quoted text clipped - 38 lines]
> >
> > Thanks.
Jezebel - 14 Jul 2005 21:06 GMT
All the macro is doing is updating fields in the document, using a very
cludgy method. The error is coming up because the macro assumes that the
document has two sections, which I guess it doesn't. Quickest fix for you is
just to delete the whole macro and update fields manually. Or insert, as the
first line of code --

On error resume next

This is not a recommended practice in general (it's telling VBA to ignore
all errors) but it's OK in this case because the errors are not harmful.

> D'oh!  That certainly would help wouldn't it.  ;-)
>
[quoted text clipped - 48 lines]
>> >
>> > Thanks.
Doug Robbins - 14 Jul 2005 23:25 GMT
Or 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

> All the macro is doing is updating fields in the document, using a very
> cludgy method. The error is coming up because the macro assumes that the
[quoted text clipped - 59 lines]
>>> >
>>> > Thanks.
Me - 15 Jul 2005 15:39 GMT
This worked perfectly.  

I used this because it's only one line of code opposed to four lines that
Doug suggested.

Thanks guys!

> All the macro is doing is updating fields in the document, using a very
> cludgy method. The error is coming up because the macro assumes that the
[quoted text clipped - 59 lines]
> >> >
> >> > Thanks.
Doug Robbins - 15 Jul 2005 21:48 GMT
My four lines would do the same as everything else that you had and the bad
practice of using On error resume next would not be needed.

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

> This worked perfectly.
>
[quoted text clipped - 70 lines]
>> >> >
>> >> > Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.