Code:
Public Sub doertie()' Declare the Application object
Dim oApplication As Inventor.Application
' Obtain the Inventor Application object.
' This assumes Inventor is already running.
Set oApplication = GetObject(, "Inventor.Application")
' Set a reference to the active document.
' This assumes a document is open.
Dim oDoc As Document
Set oDoc = oApplication.ActiveDocument
If oApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
MsgBox ("In IDW nicht möglich.")
Exit Sub
End If
If oApplication.ActiveDocument.DocumentType = kPresentationDocumentObject Then
MsgBox ("In IPN nicht möglich.")
Exit Sub
End If
If oApplication.ActiveEditObject.DocumentType = kPartDocumentObject Then
oDoc.Dirty = True
Else
Dim oAsm As AssemblyDocument
Set oAsm = ThisApplication.ActiveDocument
ForAllComponents oAsm.ComponentDefinition.Occurrences, oDoc
End If
End Sub
Sub ForAllComponents(oObjOccs As ComponentOccurrences, oDoc As Document)
' Declare the Application object
Dim oApplication As Inventor.Application
' Obtain the Inventor Application object.
' This assumes Inventor is already running.
Set oApplication = GetObject(, "Inventor.Application")
Dim oObjOcc As ComponentOccurrence
Dim oaeo As Object
For Each oObjOcc In oObjOccs
oObjOcc.Edit
Set oaeo = oApplication.ActiveEditObject
oaeo.Dirty = True
If Err.Number <> 0 Then
Err.Number = 0
GoTo NEXTCOMP
End If
ThisApplication.CommandManager.[_StartCommand] 43312
NEXTCOMP:
ForAllComponents oObjOcc.SubOccurrences, oDoc
ThisApplication.CommandManager.[_StartCommand] 43312
Next
End Sub