|
-
Oct 7th, 2005, 06:55 AM
#1
Thread Starter
New Member
cancel button not working properly while using Common dialog
hi,
I m using VB macros in the Microsoft Project Plan to convert the plan into xml using the common dialog.
Its working fine for Save the MPP into xml format.
However once i save it and then try to use the Save as menu, it captures the name of the file which i saved earlier and even if i cancel the dialog box, the file is saved using that name.
im attaching the code for reference:
DialogForm.CommonDialog1.Filter = "All Xml (*.xml)"
DialogForm.CommonDialog1.ShowSave
If (DialogForm.CommonDialog1.fileName = "") Then
End If
If (DialogForm.CommonDialog1.fileName <> "") Then
xmlFileName = DialogForm.CommonDialog1.fileName + ".xml"
anybody has any idea, why the problem is coming.
-
Oct 7th, 2005, 07:00 AM
#2
Re: cancel button not working properly while using Common dialog
VBA question...moved to Office Development.
-
Oct 7th, 2005, 08:40 AM
#3
Re: cancel button not working properly while using Common dialog
Hi,
What I normally do is set the property Cancelerror = True, which means that it will generate an error if cancel is pressed. Then you can trap it with the line "On error goto cancelled", and stick a "cancelled:" section of code at the bottom of the sub. Like so:
VB Code:
On Error GoTo cancelled:
DialogForm.CommonDialog1.Filter = "All Xml (*.xml)"
DialogForm.CommonDialog1.cancelerror = True
DialogForm.CommonDialog1.ShowSave
If (DialogForm.CommonDialog1.fileName <> "") Then
xmlFileName = DialogForm.CommonDialog1.fileName + ".xml"
Exit Sub
cancelled:
msgbox "You pressed Cancel"
Alternatively, there are builtin MSOffice Dialogs, which mean that you don't need the CommonDialog control. Check for "Dialog" in the VBA help for a fully coded example.
HTH
zaza
-
Oct 11th, 2005, 01:25 AM
#4
Thread Starter
New Member
Re: cancel button not working properly while using Common dialog
thanks a lot...the on Error thing worked...
-
Oct 11th, 2005, 12:30 PM
#5
Re: cancel button not working properly while using Common dialog
Glad to hear it. Can you mark this as "Resolved" then? Edit your first post and change the symbol to the green tick.
Cheers
zaza
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|