OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 23-03-2006, 16:10
annedeblois
Guest
 
Posts: n/a
Default Cancelling a macro when hitting the "Cancel" button

Hi,

I wrote VBA code that saves some objects' properties to a CSV file.

Here is part of the code:
Code:
Filename = CorelScriptTools.GetFileBox(dialogBoxType, dialogBoxTitle, 1)

Set fs = CreateObject("Scripting.FileSystemObject")
    fs.CreateTextFile Filename
Set f = fs.GetFile(Filename)
Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault)
Immediately following the Filename = CorelScriptTools.GetFileBox(dialogBoxType, dialogBoxTitle, 1) line, I would like to add some "error capture" features, for example if you click on the dialog's Cancel button.

I think this requires an If Then Else, but I don't know exactly what to write. Thank you so much in advance!
Reply With Quote
  #2  
Old 23-03-2006, 17:05
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Yes, if the file box was canceled then the function will return an empty string. You just need to check for this:

Code:
Filename = CorelScriptTools.GetFileBox(dialogBoxType, dialogBoxTitle, 1)

If Filename <> "" Then
    Set fs = CreateObject("Scripting.FileSystemObject")
    fs.CreateTextFile Filename
    Set f = fs.GetFile(Filename)
    Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault)
    ...
End If
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a button to toolbars to run a VBA macro Alex FAQ 4 10-05-2007 09:07
Cannot use Curveworks macros in a user witten macro??? jon46089 CurveWorks 2 02-03-2006 15:18
New macro to clip curves w.r.t. a border Gerard Hermans Macros/Add-ons 0 09-06-2003 08:50


All times are GMT -5. The time now is 12:54.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com