Public Sub ExportToDxf()
Set oApp = GetObject(, "Inventor.Application")
If Err Then
MsgBox "Inventor must be running."
End
End If
If oApp.Documents.Count = 0 Then
MsgBox "At leaset one opened document must exist."
End
End If
Dim oDoc As Inventor.Document
For Each oDoc In oApp.Documents
If (oDoc.DocumentType <> kDrawingDocumentObject) Then
MsgBox "Error:Document type is not drawing"
Else
Dim sFname As String 'Get document's full file name
sFname = oDoc.FullFileName
sFname = Left$(sFname, Len(sFname) - 3) & "DXF" 'Rename extension
Call ThisApplication.CommandManager.PostPrivateEvent(kFileNameEvent, sFname)
Call ThisApplication.CommandManager.StartCommand(kFileSaveCopyAsCommand)
End If
Next
End Sub