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

@WCrihfield 

Thanks for the guidance. With your help, I'm really close.

If I run the iLogic manually, does exactly what I need it to do.

But, if I attach it to an Event Trigger so that on Drawings it runs "After Open Document, it errors.

What am I missing?

steveh_0-1668631215820.png

 

'This logic runs thru all of Drawings Styles and updates them.
Sub Main()
	OpenDoc = ThisDoc.Document
	oStyles = OpenDoc.StylesManager.Styles
	
'Sets Update dialog to initially False
Dim RequiresUpdate = False
	
'Runs thru all Styles and switches to RequiresUpdate to True
		For Each oStyle As Style In oStyles
			If Not oStyle.UpToDate Then RequiresUpdate = True
		Next	
	
	
If RequiresUpdate = True Then	
	'		Pop up message asking if you want to update styles
		oAns = MessageBox.Show("Update to Current Drawing Styles?", "Styles Update", MessageBoxButtons.YesNoCancel,
		MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2)
	
	
	If oAns = DialogResult.Yes Then
		'Runs thru all Styles and update them, if needed
		For Each oStyle As Style In oStyles
			If Not oStyle.UpToDate Then oStyle.UpdateFromGlobal
		Next
	End If
'Tells user that Styles have been updated.
'	MessageBox.Show("Drawing Styles have been Updated!" + vbCrLf + vbCrLf + "PLEASE Review all Dimensions and Balloons" & vbCr & oFile)
End If


	Try : OpenDoc.Save : Catch : End Try

If oAns = DialogResult.Yes Then
'Tells user that Styles have been updated.
	MessageBox.Show("Drawing Styles have been Updated!" + vbCrLf + vbCrLf + "PLEASE Review all Dimensions and Balloons" & vbCr & oFile)
End If

End Sub

 

Best,

Steve Hilvers
Inventor Certified User / Vault Professional Influencer