Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VBA Macro - Create a PDF File with Hyperlinks from a IDW File?

0 REPLIES 0
Reply
Message 1 of 1
Olga_Ya
740 Views, 0 Replies

VBA Macro - Create a PDF File with Hyperlinks from a IDW File?

Could anybody help me please? I cannot find information about "How to create PDF file with Hyperlink? "

I use this VBA macro code that create PDF file automatically from a IDW file (Autodesk Inventor 2011): 

 

Public Sub SaveAsPDF()
' Get the PDF translator Add-In.
Dim oPDFTrans As TranslatorAddIn
Set oPDFTrans = ThisApplication.ApplicationAddIns.ItemById( _
"{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
If oPDFTrans Is Nothing Then
MsgBox "Could not access PDF translator."
Exit Sub
End If

' Create some objects that are used to pass information to
'the translator Add-In.
Dim oContext As TranslationContext
Set oContext = ThisApplication.TransientObjects.CreateTranslationContext
Dim oOptions As NameValueMap
Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap
If oPDFTrans.HasSaveCopyAsOptions(ThisApplication.ActiveDocument, _
oContext, oOptions) Then
' Set to print all sheets. This can also have the value
' kPrintCurrentSheet or kPrintSheetRange. If kPrintSheetRange
' is used then you must also use the CustomBeginSheet and
' Custom_End_Sheet to define the sheet range.
oOptions.Value("Sheet_Range") = kPrintAllSheets

' Other possible options...
'oOptions.Value("Custom_Begin_Sheet") = 1
'oOptions.Value("Custom_End_Sheet") = 5
oOptions.Value("All_Color_AS_Black") = False
'oOptions.Value("Remove_Line_Weights") = True
oOptions.Value("Vector_Resolution") = 300

' Define various settings and input to provide the translator.
oContext.Type = kFileBrowseIOMechanism
Dim oData As DataMedium
Set oData = ThisApplication.TransientObjects.CreateDataMedium

' ********************************************************
Set oSheet = ThisApplication.ActiveDocument.ActiveSheet

sDocFulldisplayName = oSheet.Parent.FullDocumentName
sDocDisplayName = oSheet.Parent.DisplayName

CurrentDocumentNameLength = Len(sDocFulldisplayName)
CurrentDocumentNameLength = CurrentDocumentNameLength - Len(sDocDisplayName)

If (Right(sDocDisplayName, 3) <> "idw") And (Right(sDocDisplayName, 3) <> "iam") And (Right(sDocDisplayName, 3) <> "ipt") Then
CurrentDocumentNameLength = CurrentDocumentNameLength - 4
End If

ExportedFileName = Left(sDocFulldisplayName, CurrentDocumentNameLength)

' ********************************************************

Set oPartsList = oSheet.Parent
For Each oPart In oPartsList.ReferencedDocuments
Set oDoc = oPart

For Each oPropSet In oDoc.PropertySets
For Each OProp In oPropSet
If OProp.DisplayName = "Bestandsnummer" Then
ExportedFileName = ExportedFileName & OProp.Value & ".pdf"
End If
Next
Next
Next

' *******************************************************************
oData.FileName = ExportedFileName

' Call the translator.
Call oPDFTrans.SaveCopyAs(ThisApplication.ActiveDocument, _
oContext, oOptions, oData)
End If
End Sub

 

Is it possible to create PDF file with Hyperlinks to open another PDF files?  

Many thanks in advance!

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report