Extracting AutoCAD drawing name

Discussion in 'AutoCAD' started by Lynne, Jul 22, 2004.

  1. Lynne

    Lynne Guest

    Could you please help me get the drawing name and path.
    Thank you
     
    Lynne, Jul 22, 2004
    #1
  2. Lynne

    Jürg Menzi Guest

    Hi Lynne

    Did you read the answers in thread 'Exporting text from AutoCAD to Excel'?

    Cheers
     
    Jürg Menzi, Jul 22, 2004
    #2
  3. Lynne

    Lynne Guest

    Yes I did Thanks
    My programme is running nicely.
    But I want to automate saving the excel file to the same name as the drawing from which I am extracting the text.
    It doesnt seem to give me the drawing name and path.
    Lynne
     
    Lynne, Jul 22, 2004
    #3
  4. Lynne

    Joe Sutphin Guest

    If you are creating a new drawing [that has not been saved] then use

    ThisDrawing.Path & "\" & ThisDrawing.Name

    If your drawing has been saved or you are opening a pre-existing drawing
    then use

    ThisDrawing.FullName

    Joe
    --

    drawing from which I am extracting the text.
     
    Joe Sutphin, Jul 22, 2004
    #4
  5. Lynne

    Jürg Menzi Guest

    Hi Lynne

    This function grabs the dwg name and path and returns it with
    the requested extension, eg.:

    CreateFileNameByDwg(".xls")
    X:\Projects\MyDrawings\Test.xls

    Public Function CreateFileNameByDwg(FilExt As String) As String
    'Requires a reference to 'Microsoft Scripting Runtime'

    Dim FilObj As FileSystemObject

    Set FilObj = CreateObject("Scripting.FileSystemObject")

    With ThisDrawing
    CreateFileName = .Path & "\" & FilObj.GetBaseName(.Name) & FilExt
    End With

    Set FilObj = Nothing

    End Function

    Cheers
     
    Jürg Menzi, Jul 22, 2004
    #5
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.