Sub TEMPLATE_PDF_CAD_PROGRAM() Dim OpenDoc As Inventor.Document Dim DocFile As Inventor.Document Dim AssemblyDoc As AssemblyDocument Dim AssemblyDef As AssemblyComponentDefinition OpenDoc = ThisApplication.ActiveDocument Dim AskContinue As String AskContinue = MessageBox.Show("Continue?", "Title", MessageBoxButtons.YesNo) If AskContinue = vbYes Then If OpenDoc.DocumentType = kAssemblyDocumentObject Then AssemblyDoc = OpenDoc AssemblyDef = AssemblyDoc.ComponentDefinition For Each DocFile In OpenDoc.AllReferencedDocuments 'Get the current part / assembly's path and file name without extension Dim CurrDocName As String CurrDocName = ThisDoc.PathAndFileName(False) 'without extension is False 'Create the drawing documents full path and file name with extension Dim DrawDocName As String DrawDocName = CurrDocName & ".idw" 'check for existing file If Dir(myXLS_File) <> "" Then 'drawing exists so perform tasks 'Open the drawing document for this part / assembly Dim DrawDoc As DrawingDocument DrawDoc = ThisApplication.Documents.Open(DrawDocName, True) 'True opens visibly 'SaveAs this drawing with _CAD in the name Dim DrawDocNew As DrawingDocument DrawDocNew = DrawDoc.SaveAs (CurrDocName & "_CAD.idw", False) 'SaveCopyAs is True '''''''''''''''''''''''''''' ''''''''''''''''''''''''''' 'Do all your other tasks to DrawDocNew 'save DrawDocNew 'close DrawDocNew Try DrawDoc.Close() Catch ex As Exception 'Do nothing if failed to close main drawing and continue End Try 'If this part / assembly does not have a drawing Else 'do nothing End If Next End If End If End Sub