How to define clicking of buttons "Save" or "Save As" by user ?

A

avkokin

Hello.
I need to define clicking of the buttons "Save" or "Save As" by user
on the tollbar. Next I will add to name of file of the value of one
bookmark. How can I define it?
Is it correct:

if Activedocument.Saved = False Then
Activedocument.Saveas ...
.... my code...

Thank you very much!
 
D

Doug Robbins - Word MVP

I suspect that what you are trying to determine is if the document has ever
been saved, not just if it has been changed since is was saved, which is all
the If ActiveDocument.Saved = False will reveal.

You can check if it has ever been saved as follows:

If Len(ActiveDocument.Path) = 0 Then
MsgBox "The document has never been saved."
Else
MsgBox "The document has been saved, but may need to be saved again if
it has been changed."
End If


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

avkokin

Thank's, but I want to define clicking on the button "Save" from the
tollbar. Yes, if this document not saved then should be show dialogue
"Save As" and next I want to add into field "Name of the file" text
from one bookmark. But I not know how to do it. User should click on
the button "Save" and get into field "Name of the file" text from one
bookmark. How to open this dialogue with text of bookmark?
 
G

Graham Mayor

How about

Sub FileSave()
Dim fName As String
On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then
fName = ActiveDocument.Bookmarks("Bookmark1").Range
If Len(fName) = 0 Then
MsgBox "File naming bookmark is empty or missing." & vbCr & _
"Document has not been saved"
Exit Sub
End If
ActiveDocument.SaveAs fName & ".doc"
Else
ActiveDocument.Save
End If
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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