Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: TONELLAL

What are you attempting to use that document variable for later in your macro?  You may need to define it as its true document type (PartDocument or AssemblyDocument) before it will allow certain actions/access related to it.

Here is one approach (of many):

Dim oDocType As DocumentTypeEnum
Set oDocType = ThisApplication.ActiveDocumentType
If oDocType = kPartDocumentObject Then
	Dim oPDoc As PartDocument
	Set oPDoc = ThisApplication.ActiveDocument
	GoTo PartStart '(place in code dealing with PartDocument stuff)
ElseIf oDocType = kAssemblyDocumentObject Then
	Dim oADoc As AssemblyDocument
	Set oADoc = ThisApplication.ActiveDocument
	GoTo AsmStart '(place in code dealing with AssemblyDocument stuff)
End If

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' :thumbs_up:.

If you have time, please... Vote For My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)