How to open dialogue SaveAs but the field "Name of file" should hasas name my bookmark?

A

avkokin

Hello.
There is the macro for saving the document with name from bookmark
(thank's G.Mayor and D.Robbins).

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

I need to show dialogue Sava As that user can select any folder for
saving document. But the field "Name of File" should has as name my
bookmark. Is it probably? How? I did so temporary:
Sub FileSave()
Dim fName As String
Dim PathName As String
PathName = "c:\"
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 PathName & fName & ".doc"
Else
ActiveDocument.Save
End If
End Sub
 
H

Helmut Weber

Hi Anton,

like that:

Sub Test10()
Dim oDlg As Dialog
Set oDlg = Dialogs(wdDialogFileSaveAs)
oDlg.name = ActiveDocument.Bookmarks("Test").Range.Text
oDlg.Show
End Sub

--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP
 

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