Vb,Net Event Macro - Run On Save Problem

Vb,Net Event Macro - Run On Save Problem

isocam
Collaborator Collaborator
257 Views
1 Reply
Message 1 of 2

Vb,Net Event Macro - Run On Save Problem

isocam
Collaborator
Collaborator

Can anybody help??

 

I have the following Vb.Net source code that, eventually, will convert an Inventor "idw" file to a "pdf" file.

 

Private Sub m_applicationEvents_OnSaveDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_applicationEvents.OnSaveDocument
Try
If BeforeOrAfter = EventTimingEnum.kBefore Then
PartNumber = LCase(DocumentObject.DisplayName)

If Instr(PartNumber, "idw") > 0 Then
DrawingFolderPath = "C:\Users\djsmi\OneDrive\Desktop\"

PdfFileName = Replace(PartNumber, "idw", "pdf")

PdfFileName = DrawingFolderPath + PdfFileName

MsgBox("Pdf File Name = " + PdfFileName)

'oDoc.SaveAs(PdfFileName, True)
End If
End If
Catch ex As Exception
End Try
End Sub

 

Does anybody know how I can incorporate the line shown in RED so that it saves the Pdf file?

 

Many thanks in advance!!!

 

Darren

 

 

 

0 Likes
258 Views
1 Reply
Reply (1)
Message 2 of 2

JelteDeJong
Mentor
Mentor

try something like this:

If (DocumentObject.DocumentType = DocumentTypeEnum.kDrawingDocumentObject) Then
    DocumentObject.SaveAs(PdfFileName, True)
End If

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes