Automatically running a macro, ok if open manually, issues using PS or VBA

Started by visio, October 29, 2014, 10:19:52 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

visio

Visio 2010 Standard

I have a Visio diagram that uses smart shapes and excel as a data source. Every day I need to open the visio diagram and run a macro to update the diagram and then save it as a webpage. I have a macro that does this and I have automted this so that the macro always runs every time the diagram is opened. See link for how this is done.

http://www.visguy.com/2009/05/13/data-refresh-on-open/

So far everything is good. I wanted to take this a step further and automate the opening of the diagram so  I don;t need to do this myself manually each day.

When I try to do this using either VBA or Excel I get a message saying Runtime error -2032465730 This operation is not supported in Microsoft Visio Standard 2010.

When I open the same diagram manually everything is fine and the diagram runs the macros and updates as expected.

All the code is doing is creating a visio object then opening the diagram.

set visio = createobject("Visio.Application") '##create visio object
visio.visible = true
visio.documents.open "c:\myvisondiagram.vsd"

Any ideas?

Croc

Try a direct call the macro. Without event DocumentOpened.
Like this:
    Dim vApp
    Dim vDoc
    Set vApp = CreateObject("Visio.Application")
    Set vDoc = vApp.Documents.Open("c:\myvisondiagram.vsd")
    Call vDoc.RefreshData 'macro in c:\myvisondiagram.vsd
    Call vDoc.SavePDF 'another macro
    vDoc.Close
    vApp.Quit