Discussion:
save as dialog box
(too old to reply)
ptti
2004-02-03 13:29:24 UTC
Permalink
I am trying to redefine the saving functions in autocad using VBA. I have a function in which I do the following code:

ThisDrawing.SendCommand "(getfiled ""SAVEAS"" ""C:"" ""AutoCAD 2000 Drawing (*.dwg);AutoCAD R14 Drawing (*.dwg"" 11)" & vbCr

What I was wondering is how you can grab which File Type the user selected to save the file as (2000 or R14) so that I can then use ThisDrawing.SaveAs "Name","Type". Any ideas?

Thanks in advance.
Jason Piercey
2004-02-03 15:10:12 UTC
Permalink
You may find more appropriate information and receive better
responses by posting future VBA related questions in the VBA
discussion group, available at:

By NNTP discussion group reader at
news://discussion.autodesk.com/autodesk.autocad.customization.vba

By HTTP (web-based) interface at
http://discussion.autodesk.com/forum.jspa?forumID=33
--
-Jason
Member of the Autodesk Discussion Forum Moderator Program
Post by ptti
I am trying to redefine the saving functions in autocad using VBA. I have a function in
ThisDrawing.SendCommand "(getfiled ""SAVEAS"" ""C:"" ""AutoCAD 2000 Drawing
(*.dwg);AutoCAD R14 Drawing (*.dwg"" 11)" & vbCr
Post by ptti
What I was wondering is how you can grab which File Type the user selected to save the
file as (2000 or R14) so that I can then use ThisDrawing.SaveAs "Name","Type". Any ideas?
Post by ptti
Thanks in advance.
Phil Kenewell
2004-02-03 15:20:41 UTC
Permalink
Instead of using a SendCommand statement, why not just use the SaveAs
Method?

object.SaveAs FileName, FileType [, SecurityParams]

Simple Example:
Dim Filenam As String

Filenam = Inputbox, "File Name:", "Save File As:"
ThisDrawing.SaveAs Filnam, ac2000_dwg

If you want to make the File Type selectable, you may be better off using
the common file dialog. Check out This example on VbDesign.net:

http://www.vbdesign.net/modules.php?s=&name=Code_Trout&cats=24&view=112


--
Phil Kenewell
----------------------
Gage Designer
North American Lighting, Inc.
ECCAD
2004-02-03 15:37:18 UTC
Permalink
Suggestion:
Do something like:
sFileName = ThisDrawing.SendCommand "(getfiled ""SAVEAS"" ""C:"" ""AutoCAD Drawing(*.dwg)" & vbCr
Then:
sDwgType = Right$(sFileName, 3)
Then:
Switch (sDwgType)

Bob
Phil Kenewell
2004-02-03 15:51:32 UTC
Permalink
Bob,
sFileName = ThisDrawing.SendCommand "(getfiled...
I don't think the SendCommand method will return the result of (getfiled)
like that. Additionally, it would be difficult to pass the result of
(getfiled) to something, then retrieve it for use in the VBA function
because SendCommand runs asynchronously when the command sent pauses for
user input. You would have to clear a USER sysvar then include a "(setvar"
into the SendCommand string. Then you may be able to loop the VBA function
until the USER sysvar has a value. I not sure if it will work.
ECCAD
2004-02-03 16:19:51 UTC
Permalink
Phil,
I guess I'm having a bad-hair day. Using (getfiled won't return a value (is across the fence), cannot pass vars directly. Bummer. Is there a VBA 'getfiled' or such that could do the same thing ? Return a fully qualified path/filename/ext to look at ?
Bob
Phil Kenewell
2004-02-03 18:04:13 UTC
Permalink
Bob,

Check out my above message to ptti. You have to use the common file dialog
dll in windows. I included a link to an example for making a file dialog
class module that's very useful.
ECCAD
2004-02-03 19:02:34 UTC
Permalink
Phil,
How about doing a ThisDrawing.SendCommand "(setq a (getfiled...))"
Followed by ThisDrawing.SendCommand "(setvar "MODEMACRO" a)"
The VBA code should be able to 'read' that Var, and take action, based on last (3) char's ?

Bob
Phil Kenewell
2004-02-03 19:10:16 UTC
Permalink
Bob,
As I said above, the SendCommand method is asynchronous. The code will
continue on to the next SendCommand before you get a chance to use the File
Dialog and will cause an error. (The VBA program will not pause while your
paused for input within the (getfiled) function - It will keep running.)
Post by ECCAD
Phil,
How about doing a ThisDrawing.SendCommand "(setq a (getfiled...))"
Followed by ThisDrawing.SendCommand "(setvar "MODEMACRO" a)"
The VBA code should be able to 'read' that Var, and take action, based on last (3) char's ?
Bob
Phil Kenewell
2004-02-03 16:19:54 UTC
Permalink
Bob,
sFileName = ThisDrawing.SendCommand "(getfiled...
I don't think the SendCommand method will return the result of (getfiled)
like that. Additionally, it would be difficult to pass the result of
(getfiled) to something, then retrieve it for use in the VBA function
because SendCommand runs asynchronously when the command sent pauses for
user input. You would have to clear a USER sysvar then include a "(setvar"
into the SendCommand string. Then you may be able to loop the VBA function
until the USER sysvar has a value. I not sure if it will work.
Continue reading on narkive:
Loading...