error on save

  • Thread starter VinceB1 via OfficeKB.com
  • Start date
V

VinceB1 via OfficeKB.com

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
 
C

Cindy M.

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,

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.

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 :)
 
V

VinceB1 via OfficeKB.com

Cindy said:
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 :)

Thanks Very Much Works a dream :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top