Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 09-09-2015, 06:03 PM
macropod's Avatar
macropod macropod is offline Using VBA to convert AutoCAD into WMF Windows 7 64bit Using VBA to convert AutoCAD into WMF Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,514
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Here's an article about Early and Late Binding: https://support.microsoft.com/en-us/kb/245115.

An essential distinction between early binding and late binding is that, to use early binding, you must set a reference to the application (in this case AutoCAD) in the VBE via Tools|References. Once you do that, though, you can use all of the application's methods, procedures and properties much more easily than you can using late binding.

Using early binding, your code might become:
Code:
Sub Convert_dxf()
Dim AcadApp As AutoCAD.Application
Dim AcadDoc As AutoCAD.Document
Dim SS As AutoCAD.AcadSelectionSet
Set AcadApp = New AutoCAD.Application
With AcadApp
  .Visible = False
  Set AcadDoc = .Documents.Open("C:\drawing.dxf")
  With AcadDoc
    Set SS = .SelectionSets("SS")
    .Export "C:\drawing.wmf", "WMF", SS
    .Close SaveChanges:=False
  End With
  .Quit
End With
Set SS = Nothing: Set AcadDoc = Nothing: Set AcadApp = Nothing
End Sub
Note: I don't have AutoCAD, so I don't know what it's VB object model looks like or what methods, procedures and properties are available. Accordingly, you'll have to do your own work on that front. For testing purposes, you'll also want to comment-out the line:
.Visible = False
otherwise you could end up with a plethora of hidden and orphaned AutoCAD sessions running in the background.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
auto export, autocad, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you convert to .MOV? pmr8888 PowerPoint 0 11-30-2011 04:32 PM
Outlook 2010 attach autocad drawing knorre Outlook 0 10-31-2011 12:46 AM
Pasting into worksheet from Autocad for Mac davisb Excel 0 08-29-2011 01:59 PM
Access, Visio & Autocad oo0tommyk0oo Visio 0 05-16-2011 02:46 PM
Using VBA to convert AutoCAD into WMF embed autocad drawing in word document prints very light gbehm@broan.com Drawing and Graphics 1 03-15-2011 08:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:39 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft