Hello: I would like to allow the user to use the openFileDialog to select a windows metafile (wmf) of their choice and insert into a drawing. I searched all the wmf, insert, import ...etc. on this site to try and find how I can do this...but was unable to find solution.
Has anyone done anything like this before?
Here's the code I use to open a drawing..it's not happy when i try it w/ a wmf.
Public Sub OpenWMF()
Dim myFileDialog As New System.Windows.Forms.OpenFileDialog()
'Dim myFileDialog As New System.Windows.Forms.OpenFileDialog()
myFileDialog.Filter = "Image Vector files|*.wmf"
Dim myDiagResult As System.Windows.Forms.DialogResult
myDiagResult = myFileDialog.ShowDialog()
Dim doc As Document
doc = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor
ed = doc.Editor
If myDiagResult = System.Windows.Forms.DialogResult.OK Then
Try
Dim myFile As String
myFile = myFileDialog.FileName.ToString()
[color=red]'bombs on this line:[/color]
Application.DocumentManager.Open(myFile.ToString(), False)
Application.DocumentManager.MdiActiveDocument.LockDocument(DocumentLockMode.AutoWrite, Nothing, Nothing, True)
'if the drawing is saved so that paperspace was showing, this code makes sure that model space is the default setting for the user to see.
ApplicationServices.Application.SetSystemVariable("TileMode", 1)
Me.Close()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
MsgBox(ex.Message)
End Try
End If
End Sub
any dirrection is truly appreciated.
Thanks,
proctor