The application events fire twice, once before the event (in this case activating the document) and again afterwards.
so you need an if query to tell it when to do so.
I've added this line in just after I've declare the addinserver as below:
Private WithEvents oAppEvents As ApplicationEvents
Namespace YourGreatAddin
<ProgIdAttribute("YourGreatAddin.StandardAddInServer"), _
GuidAttribute("E6EA2F87-0494-4C0D-9E05-63DEB55637FB")> _
Public Class StandardAddInServer
Implements Inventor.ApplicationAddInServer
'Application events object
Private WithEvents oAppEvents As ApplicationEvents
Then this code further down, after all the addin activation and user interface subs:
This gives you the option of firing the code before or after, either way it will only fire once.
Private Sub oAppEvents_OnActivateDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles oAppEvents.OnActivateDocument
'Will fire after activating document
If BeforeOrAfter = EventTimingEnum.kBefore Then
'Put all your cool code here
End If
'Will fire after activating document
If BeforeOrAfter = EventTimingEnum.kAfter Then
'Put all your cool code here
End If
End Sub
with the line oAppevents line added you should be able to select "oAppEvents" from the left dropdown and the right will the show a list of all available actions. (this is based upon Visual studio pro 2010)
Hope this helps.