Jump to content

Open AutoCAD from Word and export drawing to wmf


Recommended Posts

I am in the process of developing a Word template to consolidate the design calculations into one document. The design software we use creates dxf files. I am trying to open specific drawings, as determined by the user, and convert them to wmf so they can be imported into the word template. The following code is what I have for the export. I have added comments in blue to explain my concerns. Note that the following code is only for exporting the drawing and is being run from word.


Sub Convert_3DBuild()

Dim iRow As Integer

Dim AcadApp As Object

Dim SS 'As AcadSelectionSet
Word does not let me declare this variable which is why it is commented out.



On Error Resume Next

Set AcadApp = GetObject(, "AutoCAD.Application")

If Err.Number 0 Then

Set AcadApp = CreateObject("AutoCAD.Application")

End If

AcadApp.Visible = True


AcadApp.Documents.Open ("C:\drawing.dxf")


Set SS = AcadApp.ActiveDocument.SelectionSets.Add("SS")

Set SS = Nothing '
AutoCAD help states that if the selection set is Nothing, the entire drawing will be selected, but it does not seem to be the case here.



AcadApp.ActiveDocument.Export "C:\drawing", "WMF", SS

' because SS is not recognized by AutoCAD as a selection set, AutoCAD waits for the user to select the parts before continuing.

' The selection needs to be automatic


AcadApp.ActiveDocument.Close savechanges:=False

' If AcadApp.Documents.Count = 1 Then

' AcadApp.ActiveDocument.sendcommand "Exit" & vbCr

is there a way to exit AutoCAD with out using SendCommand which again requires user interaction to select not to save changes to a blank drawing?


' End If

Set AcadApp = Nothing

End Sub

I am open to other methods to accomplish the same task.


Thank you in advance for your assistance.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...