AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using VBA to extract an attached image's name

1 REPLY 1
Reply
Message 1 of 2
Anonymous
426 Views, 1 Reply

Using VBA to extract an attached image's name

Hello community!

 

I have question regarding the VBA Enabler add-in for AutoCAD 2017. Does anyone know of a way to extract the name of an image using VBA after a user double clicks that particular image? Any ideas/insight on this odd request would be much appreciated.

 

Regards,

1 REPLY 1
Message 2 of 2
norman.yuan
in reply to: Anonymous

By "image", I assume you mean raster image inserted into AutoCAD drawing. Finding raster image's file name programmatically is not an odd thing to do, Rather, it is quite simple. Following VBA code shows the file name of an image when user selects it:

 

Public Sub GetImageFileName()

    Dim ent As AcadEntity
    Dim pt As Variant
    Dim image As AcadRasterImage
    
    ThisDrawing.Utility.GetEntity ent, pt, vbCr & "Select a raster image:"
    If ent Is Nothing Then Exit Sub
    
    If TypeOf ent Is AcadRasterImage Then
        Set image = ent
        MsgBox "Image file name: " & image.ImageFile
    End If

End Sub

 

Norman Yuan

Drive CAD With Code

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost