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 / September 2006

Tip: Looking for answers? Try searching our database.

error on save

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
VinceB1 - 19 Sep 2006 10:59 GMT
I have a document that updates many bookmarks before saving document,

I have notices a problem with this in that if its a template, and its the
first time saving the work all goes well untill you click cancel on the
window that comes up asking for a location to save

this in tern causes the code to stop running and a error to occur does
anybody know a nice way around this

peice of code causing problem is

If .Type = wdTypeDocument Then
     If .ProtectionType <> wdNoProtection Then
        .Unprotect
     End If
  End If
 .Save
 
End With
End Sub

Im looking for some sort of procedure that if you decide not to save and
click cancel or close the window. the code will stop running.

Any help is greatly appreciated..

Thanks
Cindy M. - 19 Sep 2006 14:15 GMT
Hi VinceB1,

How about putting an error handler in, then handle the error as you want?

Put this at the beginning of the procedure:

On Error GoTo ErrHandler

Then before the End Sub:

'Use this to let the code terminate without going into the error handler
Exit Sub

ErrHandler:
   Select Case Err.Number
       Case 'put error number you want to handle here
           'Put actions here
       Case Else
   End select
'At this point, if you haven't used a Resume or Resume Next or GoTo
'the macro will continue on and end
End Sub

> I have a document that updates many bookmarks before saving document,
>  
[quoted text clipped - 20 lines]
> Im looking for some sort of procedure that if you decide not to save and
> click cancel or close the window. the code will stop running.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
VinceB1 - 19 Sep 2006 16:04 GMT
>Hi VinceB1,
>
[quoted text clipped - 32 lines]
>This reply is posted in the Newsgroup; please post any follow question or
>reply in the newsgroup and not by e-mail :-)

Thanks Very Much Works a dream :)
 
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.