Results 1 to 6 of 6

Thread: Inventor: Run macro when drawing is closed

  1. #1
    Member
    Join Date
    2002-05
    Posts
    47
    Login to Give a bone
    0

    Default 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

  2. #2
    I could stop if I wanted to
    Join Date
    2002-02
    Location
    Kansas
    Posts
    487
    Login to Give a bone
    0

    Default 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

  3. #3
    Member
    Join Date
    2002-05
    Posts
    47
    Login to Give a bone
    0

    Default 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

  4. #4
    Member
    Join Date
    2001-04
    Posts
    32
    Login to Give a bone
    0

    Default 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.

  5. #5
    Member
    Join Date
    2002-05
    Posts
    47
    Login to Give a bone
    0

    Default 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

  6. #6
    Member
    Join Date
    2002-05
    Posts
    47
    Login to Give a bone
    0

    Default 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

Similar Threads

  1. Inventor Macro Recorder
    By inventor.wishlist1738 in forum Inventor Wish List
    Replies: 0
    Last Post: 2009-10-20, 03:25 PM
  2. Inventor macro button
    By gerrard.hickson in forum VBA/COM Interop
    Replies: 7
    Last Post: 2009-03-22, 11:00 PM
  3. dimension changing when drawing closed.
    By shenderson in forum AutoCAD General
    Replies: 1
    Last Post: 2009-03-16, 12:39 PM
  4. Replies: 8
    Last Post: 2008-03-25, 03:12 PM
  5. Inventor API: ClientGraphics fill closed region
    By mikazakov.161199 in forum API Wish List
    Replies: 0
    Last Post: 2008-02-23, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •