VBA Macro - Create a PDF File from a IDW File

VBA Macro - Create a PDF File from a IDW File

isocam
Collaborator Collaborator
4,723 Views
2 Replies
Message 1 of 3

VBA Macro - Create a PDF File from a IDW File

isocam
Collaborator
Collaborator

Can anybody help???

 

Before I run this on Autodesk Inventor 2012, can anybody see any possible problems that I might have with the following VBA macro code?

 

Set Doc = ThisApplication.ActiveDocument

Call Doc.SaveAs("C:\Test.pdf", True)

 

All I want to do is to create a PDF file, automatically, from a IDW file without going through a PDF Printer

 

Many thanks in advance!!!

0 Likes
4,724 Views
2 Replies
Replies (2)
Message 2 of 3

isocam
Collaborator
Collaborator

Try This!!!

 

    Dim Doc As Document

 

    Set Doc = ThisApplication.ActiveDocument

 

    PdfFileName = DrawingFilePath & PartNumber & ".pdf"
   
    Call Doc.SaveAs(PdfFileName, True)

0 Likes
Message 3 of 3

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

To publish the document to a PDF, two options: 

use PrintManager. 

Dim oPM as PrintManager 
Set oPM = oDoc.PrintManger 

oPM.Printer = "Adobe PDF"
oPM.PrinteToFile  "c:\test.pdf"

 



using TranslatorAddin 

Please firstly have a look at the topic "TranslatorAddin" in the API help document. The following code sample is for your reference. Although it is written in VBA, it would need little effort to translate to C++. Please let me know if you have any difficulty. 


Sub test() 

Dim addins As ApplicationAddIns 
Set addins = app.ApplicationAddIns 

Dim oPDFAddin As TranslatorAddIn 
'Set oPDFAddin = ThisApplication.ApplicationAddIns.ItemById ("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}") 

Dim oContext As TranslationContext 
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext 
oContext.Type = kFileBrowseIOMechanism 

' Create a nameValueMap 
Dim oOptions As NameValueMap 
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap 

' Create a DataMedium object 
Dim oDataMedium As DataMedium 
Set oDataMedium = ThisApplication.TransientObjects.CreateDataMedium 

' Check 
Debug.Print oPDFAddin.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) 

If oPDFAddin.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then 
'this setting has no effect 
' oOptions.Value("All_Color_AS_Black") = "False" 'True 

End If 

'change to a path on your system 
oDataMedium.FileName = "C:\ExportPDF.pdf" 

' Publish document 
Call oPDFAddin.SaveCopyAs(ThisDocument, oContext, oOptions, oDataMedium) 
End Sub 

 

0 Likes