Macros on Start up

Macros on Start up

Anonymous
Not applicable
213 Views
1 Reply
Message 1 of 2

Macros on Start up

Anonymous
Not applicable
Hi all

How do I automaticaly start a macro that sets up my events when inventor
starts.

The macro below is in my default.ivb file and when I start inventor
I want it to start as well.


Public Sub Setup_events()

On Error Resume Next
'attach to Inventor
Set IvApp = GetObject(, "Inventor.Application")

'if Inventor isn't running, start it
If Err Then
Err.Clear
Set IvApp = CreateObject("Inventor.Application")
End If
IvApp.Visible = True

If IvApp.Documents.Count > 0 Then
Set DocEvents = IvApp.ActiveDocument.DocumentEvents
End If

On Error GoTo 0
Set AppEvents = IvApp.ApplicationEvents
'Set FileAccessEvents = IvApp.FileAccessEvents
Set UserInputEvents = IvApp.CommandManager.UserInputEvents

'etc.......

end sub
0 Likes
214 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
We've discussed this before and "I believe" the answer was make it an
add-in. It appears that the default.ivb isn't *really* loaded till you fire
off a sub from it manually or load the VB editor. I had a AutoOpen()
function that I could never get running due to this same issue.

If I'm remembering wrong I'm sure someone will correct me..

--
Sean Dotson, PE
http://www.sdotson.com
Check the Inventor FAQ for most common questions
www.sdotson.com/faq.html
----------------------------------------------------------------------------
------
"Stuart P" wrote in message
news:E7C5D59C3BCBF537A9645A7DA3EDD58D@in.WebX.maYIadrTaRb...
> Hi all
>
> How do I automaticaly start a macro that sets up my events when inventor
> starts.
>
> The macro below is in my default.ivb file and when I start inventor
> I want it to start as well.
>
>
> Public Sub Setup_events()
>
> On Error Resume Next
> 'attach to Inventor
> Set IvApp = GetObject(, "Inventor.Application")
>
> 'if Inventor isn't running, start it
> If Err Then
> Err.Clear
> Set IvApp = CreateObject("Inventor.Application")
> End If
> IvApp.Visible = True
>
> If IvApp.Documents.Count > 0 Then
> Set DocEvents = IvApp.ActiveDocument.DocumentEvents
> End If
>
> On Error GoTo 0
> Set AppEvents = IvApp.ApplicationEvents
> 'Set FileAccessEvents = IvApp.FileAccessEvents
> Set UserInputEvents = IvApp.CommandManager.UserInputEvents
>
> 'etc.......
>
> end sub
>
>
>
>
0 Likes