capturing if teh cancel button has been pressed

R

red6000

hi i have code that displays teh SAVEAS dialog box.

How can i capture if the user presses the cancel button?

Thanks.
 
J

Jonathan West

red6000 said:
hi i have code that displays teh SAVEAS dialog box.

How can i capture if the user presses the cancel button?

Thanks.

The Display and Show methods return a value that depend on the button
pressed to close the dialog. Look up the methods in the VBA Help for
details.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
R

red6000

thanks, that has moved me forward.

It doesn't look like it, but is it possible to pre-populate the saveas
dialog box with different text to the current filename (ie 'temp.doc')?

If aDoc.ReadOnly = True Then
With Dialogs(wdDialogFileSaveAs)
xSave = .Show
End With

Do While xSave = 0
response = MsgBox("You have cancelled
saving the changes. Do you want to save this document? " & aDoc.Name,
vbYesNo)
If response = vbYes Then
With Dialogs(wdDialogFileSaveAs)
xSave = .Show
End With
Else
xSave = 1
End If
Loop
aDoc.Close savechanges:=wdDoNotSaveChanges
End if
 
J

Jonathan West

red6000 said:
thanks, that has moved me forward.

It doesn't look like it, but is it possible to pre-populate the saveas
dialog box with different text to the current filename (ie 'temp.doc')?

Yes.

With Dialogs(wdDialogFileSaveAs)
.Name = "temp.doc" ' can be a full pathname
xSave = .Show
End With

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
R

red6000

ahh absolutley fantastic. The name property didn;t come up when i press the
'.' in the same way that the show property did, thats why i assumed it
wasn't possible.

Thanks a lot mate. I now how some very specific code that does 100% what I
want (there a lot more to the code than I posted).

Thanks again.
 
J

Jonathan West

red6000 said:
ahh absolutley fantastic. The name property didn;t come up when i press
the '.' in the same way that the show property did, thats why i assumed it
wasn't possible.

Many of the properties of dialogs don't, because each dialog is different.
To find out what is available you need to burrow into the Help quite a long
way. In the item on the Dialogs collection, click on the link "Displaying
built-in Word dialog boxes". On that page, click the link "Built-in dialog
box argument lists". There you can see a (relatively) complete list of the
dialogs, and the properties that you can set.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

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