I trigger a sub with an OnSave event. The class module looks like:
Option Explicit
Implements ApplicationAddInServer
Private WithEvents ApplicationEvents As ApplicationEvents
Private WithEvents oButtonHandler1 As ButtonDefinitionHandler
Private Sub ApplicationAddInServer_Activate(ByVal AddInSiteObject As
Inventor.ApplicationAddInSite, ByVal FirstTime As Boolean)
Set oApp = AddInSiteObject.Application
Set ApplicationEvents = oApp.ApplicationEvents
End Sub
Private Property Get ApplicationAddInServer_Automation() As Object
Set ApplicationAddInServer_Automation = Nothing
End Property
Private Sub ApplicationAddInServer_Deactivate()
Set oApp = Nothing
End Sub
Private Sub ApplicationAddInServer_ExecuteCommand(ByVal CommandID As Long)
'
End Sub
Private Sub ApplicationEvents_OnSaveDocument(ByVal DocumentObject As
Document, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As
NameValueMap, HandlingCode As HandlingCodeEnum)
If BeforeOrAfter = kBefore Then
ChangeProps.Change
End If
End Sub
Then my ChangeProps.Change sub looks like
Option Explicit
Dim oApp2 As Inventor.Application
Dim oDoc As Inventor.Document
Dim oPropsets As PropertySets
Dim oPropSet As PropertySet
Public Sub Change()
Set oDoc = oApp2.ActiveDocument
Set oPropsets = oDoc.PropertySets
_____________
It bombs out on the set oDoc = oApp2.ActiveDocument line... is it not an
active document if it's being saved... Or just a dumb mistake on my part..?
I used oApp 2 as oApp was already defined as a AddInSiteObject.Application
above. Maybe I'm just totally confused...
--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
-----------------------------------------------------------------------