Can I force a SAVE

D

Dave

Hi

I have designed some Word userform templates (based on
Word 2000) and I am wondering if I can force people to
Save a document as soon as it has been generated, and
before they begin to add additional text to the document
etc.

I am very much a newbie, so if this is possible, I would
appreciate lots of detail on how to please! Sample code
would be even better!

Thanks

Dave
 
C

Chuck

If you put this code in the ThisDocument module of your template it will
execute when a user tries to create a document based on the template:

Private Sub Document_New()

On Error GoTo errorhandler:

ActiveDocument.Save

errorhandler:

Select Case Err.Number
Case 4198 'command failed
MsgBox "You must save before continuing.", _
vbExclamation, _
"Save required"
ActiveDocument.Close wdDoNotSaveChanges
Case Else
MsgBox Err.Number & " " & Err.Description
End Select

End Sub
 
D

Dave

Many thanks Chuck
-----Original Message-----
If you put this code in the ThisDocument module of your template it will
execute when a user tries to create a document based on the template:

Private Sub Document_New()

On Error GoTo errorhandler:

ActiveDocument.Save

errorhandler:

Select Case Err.Number
Case 4198 'command failed
MsgBox "You must save before continuing.", _
vbExclamation, _
"Save required"
ActiveDocument.Close wdDoNotSaveChanges
Case Else
MsgBox Err.Number & " " & Err.Description
End Select

End Sub



.
 

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