how to get modeldocument name for a drawingdocument?

how to get modeldocument name for a drawingdocument?

Anonymous
Not applicable
954 Views
4 Replies
Message 1 of 5

how to get modeldocument name for a drawingdocument?

Anonymous
Not applicable

Hi,

 

I tried to print thisdrawing.modeldocument in a vba sub, but it doesn't work.

 

Thanks

 

Peter

0 Likes
Accepted solutions (1)
955 Views
4 Replies
Replies (4)
Message 2 of 5

matt_jlt
Collaborator
Collaborator
Accepted solution

Hi Peter,

 

I'm not sure if you want to print the document name or the actual model document.

 

To get the model name (from a drawing) the code is as follows:

 

VBA

Public Sub GetDrawingModelName()

    ' Get reference to the first referenced document
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument.ReferencedDocuments.Item(1)
    
    ' Get file system object
    Dim Fso As New FileSystemObject
    Debug.Print Fso.GetFileName(oDoc.FullFileName)
    
    ' Change Debug.Print to be a msgbox or any variable if you want
End Sub

  If you want to print the actual document let me know an i'll write up something for you.

 

Regards, Matt.

Message 3 of 5

Anonymous
Not applicable

Hi Matt,

 

thanks for your quick reply. It's just what I need.

 

 

MsgBox ThisApplication.ActiveDocument.ReferencedDocuments.Item(1).FullFileName

 
   

Regards

 

Peter

0 Likes
Message 4 of 5

Anonymous
Not applicable

Be aware that drawing documents can have many separate documents driving difference drawing views.

Offset 1 is just the first view the user created.  It may not be the primary document you desire.

0 Likes
Message 5 of 5

Anonymous
Not applicable

Thanks Gruff.

 

I am getting iPropeties from ipt file and table it on the drawing.I'll check there is only one ipt file referenced.

0 Likes