Sorry , I missed this line
Public g_inventorApplication As Inventor.Application
it's usually default in Inventor template in Visual studio
____________________________________________________
Imports Inventor
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Public g_inventorApplication As Inventor.Application
Sub PDF()
Dim oDoc As DrawingDocument = g_inventorApplication.ActiveEditDocument
Dim oSuffix As String = System.IO.Path.GetExtension(oDoc.FullDocumentName)
Dim oPDF As String
oPDF = Replace(oDoc.FullDocumentName, oSuffix, ".pdf")
If System.IO.File.Exists(oPDF) Then
Dim Ask2 As Object
Ask2 = MsgBox("The document already exists in the selected path!" & vbLf & vbLf & oPDF & vbLf & vbLf & "Do you want to override it?", MsgBoxStyle.YesNo, "Existing Pdf Document")
If Ask2 = vbNo Then
exit sub
End If
End If
On Error Resume Next
Call oDoc.SaveAs(oPDF, True)
End Sub