Share via

How to Activate VBA Code Within Visio When Open

Anonymous
2013-01-22T18:30:39+00:00

I have written VBA code within my Visio project.  It seems the only way I know to activate my VBA code is to open the VBA Editor and under the File, I do a Save.

Then the VBA code will work for my Visio Project.

How can I set it up such that when the Visio Project is open, the VBA Code activates ???

Im am using Visio 2003 and/or Visio 2010.

I appreciate any help you can offer.

G

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2013-01-22T23:16:48+00:00

the assumption (on my part) is that the vsoWindow event has been prefaced in the front of your code with a "withevents" statement so that you could capture it. Did you include that ? The other part is that you should not forget to assign it inside of your "document opened" handler (i.e.  set vsoWindow = application.activewindow)

al

Was this answer helpful?

0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Anonymous
    2013-01-24T18:50:08+00:00

    I finally got it to work.   The problem was that I was using the command

    Set vsoWindow = Application.ActiveWindow

    I used   Set myMouseListener = New MouseListener

    Then it work.   It turns out that my class module is called MouseListerner.

    Thank You !!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-01-23T00:00:17+00:00

    I did prefaced in the front of my code with

        Dim WithEvents vsoWindow As Visio.Window

    I followed the instruction in this link:  http://office.microsoft.com/en-us/visio-help/HV080902488.aspx

    I have the Dim With Events in the Class Module called MouseListener.

    The "ThisDocument" has the Document_DocumentOpened.  I also added the "Set vsoWindow = application.activewindow" in the Sub Document_DocumentOpened .

    This I don't have it working.

    I must not have understood you completely.

    So to see what I did, just look at the link.   I would not to activate it upon the Open event.

    Thank You !!

    G

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-01-22T22:43:08+00:00

    Thank You.   I was using the On Open of the document from the link you gave me, but I still need a to initialize the VBA code to run.

    I am using "vsoWindow_MouseDown" and "vsoWindow_MouseUp" events to detect when my mouse is click.

    I did add some sendkeys to open the VBA editor, Save and Close the VB editor and that works, but there must be a better way.

    Do you have any suggestions ??

    Thank You,

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2013-01-22T20:57:40+00:00

    Was this answer helpful?

    0 comments No comments