save as dialog box

Discussion in 'AutoCAD' started by ptti, Feb 3, 2004.

  1. ptti

    ptti Guest

    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.
     
    ptti, Feb 3, 2004
    #1
  2. 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


    (*.dwg);AutoCAD R14 Drawing (*.dwg"" 11)" & vbCr
    file as (2000 or R14) so that I can then use ThisDrawing.SaveAs "Name","Type". Any ideas?
     
    Jason Piercey, Feb 3, 2004
    #2
  3. 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, Feb 3, 2004
    #3
  4. ptti

    ECCAD Guest

    Suggestion:
    Do something like:
    sFileName = ThisDrawing.SendCommand "(getfiled ""SAVEAS"" ""C:"" ""AutoCAD Drawing(*.dwg)" & vbCr
    Then:
    sDwgType = Right$(sFileName, 3)
    Then:
    Switch (sDwgType)

    Bob
     
    ECCAD, Feb 3, 2004
    #4
  5. Bob,
    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 Kenewell, Feb 3, 2004
    #5
  6. ptti

    ECCAD Guest

    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
     
    ECCAD, Feb 3, 2004
    #6
  7. Bob,
    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 Kenewell, Feb 3, 2004
    #7
  8. 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 Kenewell, Feb 3, 2004
    #8
  9. ptti

    ECCAD Guest

    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
     
    ECCAD, Feb 3, 2004
    #9
  10. 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.)
     
    Phil Kenewell, Feb 3, 2004
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.