Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2007

Tip: Looking for answers? Try searching our database.

capturing if teh cancel button has been pressed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
red6000 - 03 Jul 2007 18:10 GMT
hi i have code that displays teh SAVEAS dialog box.

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

Thanks.
Jonathan West - 03 Jul 2007 18:21 GMT
> 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.

Signature

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

red6000 - 03 Jul 2007 18:55 GMT
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

>> hi i have code that displays teh SAVEAS dialog box.
>>
[quoted text clipped - 5 lines]
> pressed to close the dialog. Look up the methods in the VBA Help for
> details.
Jonathan West - 03 Jul 2007 19:10 GMT
> 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

Signature

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

red6000 - 03 Jul 2007 19:20 GMT
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.

>> thanks, that has moved me forward.
>>
[quoted text clipped - 7 lines]
>  xSave = .Show
> End With
Jonathan West - 03 Jul 2007 19:54 GMT
> 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.

Signature

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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.