save as dialog box

ptti

Usenet Archive
Joined
Feb 3, 2004
Messages
8
Reaction score
0
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.
 
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

By HTTP (web-based) interface at
http://discussion.autodesk.com/forum.jspa?forumID=33

ptti said:
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?
 
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
 
Suggestion:
Do something like:
sFileName = ThisDrawing.SendCommand "(getfiled ""SAVEAS"" ""C:"" ""AutoCAD Drawing(*.dwg)" & vbCr
Then:
sDwgType = Right$(sFileName, 3)
Then:
Switch (sDwgType)

Bob
 
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.
 
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
 
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.
 
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.
 
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
 
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.)
 

Latest threads

Back
Top