SaveAs Dialog, almost works....

D

dubbglubb

Hey Folks,

My word form has a button that triggers opens the SaveAs dialog using
combination of the values of several labels and a textbox as the fil
title.

Currently it works fine the first time the user initiates it.

If the user needs to save a different version of the file, wit
modified values, when they opens SaveAs again the title defaults to th
current name, rather than to the modified values.


Code
-------------------
'If OkaySave was selected, bOpenSaveAs will be true so SaveAs will run

If bOpenSaveAs = True Then

'Interupts SaveAs dialog if any fields are empty

If bEmptyFields = True Then
bEmptyFields = False
Exit Sub
End If

'Check if a path exists (and therefore the file was previously saved).
'If not then changes diectory to N:\

If ActiveDocument.Path = "" Then
WordBasic.ChDir "N:\"
End If

'Opens SaveAs Dialog with entire Job Number as filename

With Dialogs(wdDialogFileSummaryInfo)

.Title = Trim(lblNata.Caption) & Trim(txtJobNumber.Text) & Trim(lblAmend.Caption) & Trim(lblReIssue.Caption) & Trim(lblPrelimPrelim.Caption)
.Execute

End With

Dialogs(wdDialogFileSaveAs).Show
End If

-------------------


eg The Vaules may be:

lblNata.Caption = N
txtJobNumber.Text = 84392
lblAmend.Caption = a
lblReIssue.Caption = ""
lblPrelimPrelim.Caption = ""

The hence combined values may be N84392a

So N84392a appears as the SaveAs file name.

If the user Saves, the reopens the form and modifies to:

lblNata.Caption = N
txtJobNumber.Text = 84392
lblAmend.Caption = a2
lblReIssue.Caption = ""
lblPrelimPrelim.Caption = ""

SaveAs opens with N84392a, rather than the expected N84392a2.


Any ideas?

Cheers
 
D

DaveLett

Hi dubbglubb,
You need to tell the dialog box what new name you want to use. Replace your
Dialogs(wdDialogFileSaveAs).Show

with the following:

With Dialogs(wdDialogFileSaveAs)
.Name = ActiveDocument.BuiltInDocumentProperties("Title").Value
.Show
End With

HTH,
Dave
 

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