Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving 1

Status
Not open for further replies.

anastasia

Programmer
Dec 13, 2000
111
GB
Hi,

I have the following code to save & close a document within Word when the user clicks a command button:

Application.ActiveDocument.Save

Application.ActiveDocument.Close

The save part saves the file to it's original location from where it was opened, is it always guranteed tha thtis is where the document will be saved to or do I have to specify the path name etc. I do not want Word to ask the user if they want to overwrite the original file as I just want to save the file under the same name.

The Application.Close part when the document then goes to close Word asks if you want to save the document which I don't want as I am automatically saving it above how do I stop this.

I just want to automatically save the document and close it without asking the user.

Thanks.

 

Hi anastasia

Try this.....
---------------------------------------------
Sub ArtooDetoo()

If ActiveDocument.Saved = False Then

Documents.Save NoPrompt:=True, _
OriginalFormat:=wdOriginalDocumentFormat

Else
End If

End Sub
---------------------------------------------
 
and for a close statement....

----------------------------------
Sub Threepio()

If ActiveDocument.Saved = False Then

Documents.Save NoPrompt:=True, _
OriginalFormat:=wdOriginalDocumentFormat

ActiveDocument.ActiveWindow.Close

Else
ActiveDocument.ActiveWindow.Close
End If

End Sub
----------------------------------------
hope this helps?

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top