I'm not sure why this macro keeps getting hung up.
Can anyone help me with this?
Solved! Go to Solution.
I remembered running the code to save as DWG back in R2008, so I cranked up 2008 again and it worked.
Why would it not work in R2010?
Mike
@Anonymous wrote:I remembered running the code to save as DWG back in R2008, so I cranked up 2008 again and it worked.
Why would it not work in R2010?
Mike
I the other code since I couldn't get it to work in 2010.
I ended up modifying the sample from the Help file.
Mike
Public Sub SaveAsDWG()
' Get the DWG translator Add-In.
Dim DWGAddIn As TranslatorAddIn
Set DWGAddIn = ThisApplication.ApplicationAddIns.ItemById("{C24E3AC2-122E-11D5-8E91-0010B541CD80}")
'Set a reference to the active document (the document to be published).
Dim oDocument As Document
Set oDocument = ThisApplication.ActiveDocument
Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = kFileBrowseIOMechanism
' Create a NameValueMap object
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
' Create a DataMedium object
Dim oDataMedium As DataMedium
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
' Check whether the translator has 'SaveCopyAs' options
If DWGAddIn.HasSaveCopyAsOptions(oDocument, oContext, oOptions) Then
Dim strIniFile As String
strIniFile = "C:\vault workspace\Drawings\Wood_DWG.ini"
' Create the name-value that specifies the ini file to use.
oOptions.Value("Export_Acad_IniFile") = strIniFile
End If
'Set the destination file name
Dim fname As String
fname = oDocument.FullFileName
fname = Left(fname, Len(fname) - 3) & "dwg"
Dim iPath As Integer
Dim sPath As String
iPath = InStrRev(fname, "\")
sPath = Left(fname, iPath)
oDataMedium.FileName = fname
'Publish document.
Call DWGAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
End Sub