Inventor: Run macro when drawing is closed
Hi
I would like to run a macro from VBA, whenever I close drawings (of type idw and iam).
I know of the auto macros, but they works from within the drawing (that is: every drawing shall have the macro).
I have an ivb (default VBA project) that holds the macro (among others), and have made a button, so I can run it before I close drawing (but then I have to remember to do it!).
Do anyone knows how to auto-run macros from the default VBA??
Regards Claus
RE: Inventor: Run macro when drawing is closed
In your default VBA project put a call to your sub in Thisdrawing AcadDocument BeginSave event. then when ever the drawing is save your sub will be run.
Code:
'this code go in thisdrawing of your default vba project
Private Sub AcadDocument_BeginSave(ByVal FileName As String)
call mysub
end sub
RE: Inventor: Run macro when drawing is closed
Hi jwanstaett
Sorry, this is Inventor, there is no ThisDrawing part of the default vba project (socalled UserProject)...
Regards Claus
RE: Inventor: Run macro when drawing is closed
You have two options:
1. You can name a public sub AutoSave() and it will run but it must be included in the documentProject, not the devault ivb project. You would have to add this to your templates for it to work for every new document you create. This is not a good way to do this for many reasons.
2. You could write an add-in that traps the OnSaveDocument event of the ApplicationEvents object. This is a much better approach but it requires writing a vb or c++ addin project.
RE: Inventor: Run macro when drawing is closed
Hi chatcher
1. What I want to avoid.
2. Out of reach for me.
Maybe I should have the idea out of my head?
Thanks anyhow for clarifying.
Regards
Claus
Re: Inventor: Run macro when drawing is closed
Finally I got hold on the problem, with help from this source:
http://www.xtremevbtalk.com/archive/.../t-209097.html
If any should be interested!
Regards Claus