M
Mike
I use the following code to use bookmarks to put the save as filename
in the save as dialog box together. It works perfectly fine until I
cancel the save dialog. So I think I'm missing something to handle
this event. Does someone know where and what to include in the code to
not get error messages in case the cancel button is pressed?
Sub filesaveas()
Dim oStory As Range
Dim pFileName As String
Dim docTitle As String
Dim docNumber As String
Dim docRev As String
docTitle = ActiveDocument.Bookmarks("Document_title").Range.Text
docNumber = ActiveDocument.Bookmarks("document_number").Range.Text
docRev = ActiveDocument.Bookmarks("revision").Range.Text
pFileName = docNumber & "-" & docRev & "-" & docTitle
With Application.Dialogs(wdDialogFileSaveAs)
.Name = pFileName
.Show
End With
ActiveDocument.save
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oStory = Nothing
End Sub
By the way, thanks for all the great help I already got from this
group.
in the save as dialog box together. It works perfectly fine until I
cancel the save dialog. So I think I'm missing something to handle
this event. Does someone know where and what to include in the code to
not get error messages in case the cancel button is pressed?
Sub filesaveas()
Dim oStory As Range
Dim pFileName As String
Dim docTitle As String
Dim docNumber As String
Dim docRev As String
docTitle = ActiveDocument.Bookmarks("Document_title").Range.Text
docNumber = ActiveDocument.Bookmarks("document_number").Range.Text
docRev = ActiveDocument.Bookmarks("revision").Range.Text
pFileName = docNumber & "-" & docRev & "-" & docTitle
With Application.Dialogs(wdDialogFileSaveAs)
.Name = pFileName
.Show
End With
ActiveDocument.save
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
Set oStory = Nothing
End Sub
By the way, thanks for all the great help I already got from this
group.