Calling Application Project Procedure from Document Project?

Calling Application Project Procedure from Document Project?

Anonymous
Not applicable
325 Views
4 Replies
Message 1 of 5

Calling Application Project Procedure from Document Project?

Anonymous
Not applicable
I'd like to remove a bunch of code from my part and assembly templates to the application VBA project. But I can't figure out how to call a procedure in the application project from a procedure in a document project. Any help? This code is to automate our part/assembly numbering, and it has worked well in the templates, running as AutoNew macros. But I want to get rid of the duplicate code in several templates and have each template do nothing but call the common code from the application project. -- Sam Bixler Eli Lilly and Company, Indianapolis
0 Likes
326 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Yes, this is possible: 1) Copy/Paste this sub in your Default IVB: Sub RunThisMacro() MsgBox "This works!" End Sub 2) Open a part/assembly 3) Open the VBA Editor 4) Create a reference to the ApplicationProject (Tools-->Reference) 5) Copy/Paste this into the DocumentProject of your part/assembly Sub AutoSaveStartsDefaultIVBMacro() ApplicationProject.Module1.RunThisMacro End Sub If you now save your part/assembly the messagebox will appear! "Sam Bixler" wrote in message news:4163ef1d$1_1@newsprd01... > I'd like to remove a bunch of code from my part and assembly templates to > the application VBA project. But I can't figure out how to call a procedure > in the application project from a procedure in a document project. Any > help? > > This code is to automate our part/assembly numbering, and it has worked well > in the templates, running as AutoNew macros. But I want to get rid of the > duplicate code in several templates and have each template do nothing but > call the common code from the application project. > > -- > Sam Bixler > Eli Lilly and Company, Indianapolis > >
0 Likes
Message 3 of 5

Anonymous
Not applicable
Teun, Thanks for your help. Unfortunately, this fails at step 4) with the following errors: Autodesk Inventor 9: Failed to open document. Microsoft Visual Basic: Automation error Unspecified Error The References dialog box shows ApplicationProject as available for selection, and when I pick it, the location shown is correct. But it always gives the above errors when I click OK. Does it matter that the Default.ivb is located on the network? This reference step is what I was missing, but I'm unable to get it accomplished. -- Sam Bixler Eli Lilly and Company, Indianapolis "Teun Ham (IV9)" wrote in message news:4163faf2_3@newsprd01... > Yes, this is possible: > > 1) Copy/Paste this sub in your Default IVB: > > Sub RunThisMacro() > MsgBox "This works!" > End Sub > > 2) Open a part/assembly > 3) Open the VBA Editor > 4) Create a reference to the ApplicationProject (Tools-->Reference) > 5) Copy/Paste this into the DocumentProject of your part/assembly > > Sub AutoSaveStartsDefaultIVBMacro() > ApplicationProject.Module1.RunThisMacro > End Sub > > If you now save your part/assembly the messagebox will appear! > > > "Sam Bixler" wrote in message > news:4163ef1d$1_1@newsprd01... > > I'd like to remove a bunch of code from my part and assembly templates to > > the application VBA project. But I can't figure out how to call a > procedure > > in the application project from a procedure in a document project. Any > > help? > > > > This code is to automate our part/assembly numbering, and it has worked > well > > in the templates, running as AutoNew macros. But I want to get rid of the > > duplicate code in several templates and have each template do nothing but > > call the common code from the application project. > > > > -- > > Sam Bixler > > Eli Lilly and Company, Indianapolis > > > > > >
0 Likes
Message 4 of 5

Anonymous
Not applicable
As far as I know, it only works when using the Default.ivb location (C:\Program Files\Autodesk\Inventor 9\Bin\Macros\Default.ivb) I have heard that others also encountered problem when trying to use an IVB that is located at a network. It should work when using the Default.ivb location... "Sam Bixler" wrote in message news:41640517_2@newsprd01... > Teun, > > Thanks for your help. Unfortunately, this fails at step 4) with the > following errors: > > Autodesk Inventor 9: Failed to open document. > > Microsoft Visual Basic: Automation error Unspecified Error > > The References dialog box shows ApplicationProject as available for > selection, and when I pick it, the location shown is correct. But it always > gives the above errors when I click OK. Does it matter that the Default.ivb > is located on the network? > > This reference step is what I was missing, but I'm unable to get it > accomplished. > -- > Sam Bixler > Eli Lilly and Company, Indianapolis > > "Teun Ham (IV9)" wrote in > message news:4163faf2_3@newsprd01... > > Yes, this is possible: > > > > 1) Copy/Paste this sub in your Default IVB: > > > > Sub RunThisMacro() > > MsgBox "This works!" > > End Sub > > > > 2) Open a part/assembly > > 3) Open the VBA Editor > > 4) Create a reference to the ApplicationProject (Tools-->Reference) > > 5) Copy/Paste this into the DocumentProject of your part/assembly > > > > Sub AutoSaveStartsDefaultIVBMacro() > > ApplicationProject.Module1.RunThisMacro > > End Sub > > > > If you now save your part/assembly the messagebox will appear! > > > > > > "Sam Bixler" wrote in message > > news:4163ef1d$1_1@newsprd01... > > > I'd like to remove a bunch of code from my part and assembly templates > to > > > the application VBA project. But I can't figure out how to call a > > procedure > > > in the application project from a procedure in a document project. Any > > > help? > > > > > > This code is to automate our part/assembly numbering, and it has worked > > well > > > in the templates, running as AutoNew macros. But I want to get rid of > the > > > duplicate code in several templates and have each template do nothing > but > > > call the common code from the application project. > > > > > > -- > > > Sam Bixler > > > Eli Lilly and Company, Indianapolis > > > > > > > > > > > >
0 Likes
Message 5 of 5

Anonymous
Not applicable
Teun, That was it. Frustrating to have to copy the default project to all users' individual machines instead of just pointing all to the network server. But this works! Thanks very much. -- Sam Bixler Eli Lilly and Company, Indianapolis "Teun Ham (IV9)" wrote in message news:416407bd$1_2@newsprd01... > As far as I know, it only works when using the Default.ivb location > (C:\Program Files\Autodesk\Inventor 9\Bin\Macros\Default.ivb) > I have heard that others also encountered problem when trying to use an IVB > that is located at a network. > > It should work when using the Default.ivb location... > > "Sam Bixler" wrote in message > news:41640517_2@newsprd01... > > Teun, > > > > Thanks for your help. Unfortunately, this fails at step 4) with the > > following errors: > > > > Autodesk Inventor 9: Failed to open document. > > > > Microsoft Visual Basic: Automation error Unspecified Error > > > > The References dialog box shows ApplicationProject as available for > > selection, and when I pick it, the location shown is correct. But it > always > > gives the above errors when I click OK. Does it matter that the > Default.ivb > > is located on the network? > > > > This reference step is what I was missing, but I'm unable to get it > > accomplished. > > -- > > Sam Bixler > > Eli Lilly and Company, Indianapolis > > > > "Teun Ham (IV9)" wrote in > > message news:4163faf2_3@newsprd01... > > > Yes, this is possible: > > > > > > 1) Copy/Paste this sub in your Default IVB: > > > > > > Sub RunThisMacro() > > > MsgBox "This works!" > > > End Sub > > > > > > 2) Open a part/assembly > > > 3) Open the VBA Editor > > > 4) Create a reference to the ApplicationProject (Tools-->Reference) > > > 5) Copy/Paste this into the DocumentProject of your part/assembly > > > > > > Sub AutoSaveStartsDefaultIVBMacro() > > > ApplicationProject.Module1.RunThisMacro > > > End Sub > > > > > > If you now save your part/assembly the messagebox will appear! > > > > > > > > > "Sam Bixler" wrote in message > > > news:4163ef1d$1_1@newsprd01... > > > > I'd like to remove a bunch of code from my part and assembly templates > > to > > > > the application VBA project. But I can't figure out how to call a > > > procedure > > > > in the application project from a procedure in a document project. > Any > > > > help? > > > > > > > > This code is to automate our part/assembly numbering, and it has > worked > > > well > > > > in the templates, running as AutoNew macros. But I want to get rid of > > the > > > > duplicate code in several templates and have each template do nothing > > but > > > > call the common code from the application project. > > > > > > > > -- > > > > Sam Bixler > > > > Eli Lilly and Company, Indianapolis > > > > > > > > > > > > > > > > > > > >
0 Likes