Visio Guy

Visio Discussions => General Visio => Topic started by: Michelle on January 22, 2013, 07:58:37 PM

Title: Trying to create a Macro to run a report
Post by: Michelle on January 22, 2013, 07:58:37 PM
As the subject states, I would like to create a Macro to run a report.  To make it as easy as possible for the user, I want a Command button that they click and *poof* there's your report.  I have created the report definition, and saved it to the document (visio template).  I also have a command button inserted into the template.  I then created a Macro (or so I thought) by recording a Macro as I went thru the steps of Clicking on Review --> Shape reports, etc to create the report.

But I can't seem to get anything to happen when I click on the button. 

I am running 2010. 

Any help will be greatly appreciated!

Michelle
Title: Re: Trying to create a Macro to run a report
Post by: MacGyver on January 29, 2013, 11:53:07 PM
I use the following line of code, however my report definition is saved to a separate file and not imbedded in the document itself (mine are saved to my My Documents folder (the default location)).

Try fooling around with the following line of Code, as i said it works for me
Visio.Application.Addons("VisRpt").Run ("/rptDefName=Parts List.vrd/rptOutput=EXCEL_SHAPE")
Title: Re: Trying to create a Macro to run a report
Post by: Michelle on January 30, 2013, 04:37:17 PM
Thanks, Mac...

I've been playing with it, but being so new to VBA, I'm running into a roadblock.

I tried
Sub Report()

Visio.Application.Addons("VisRpt").Run ("/rptDefName=Diebold Equipment.vrd/rptOutput=EXCEL_SHAPE")

End Sub


and also
Sub Report(shp As Visio.Shape)

Visio.Application.Addons("VisRpt").Run ("/rptDefName=Diebold Equipment.vrd/rptOutput=EXCEL_SHAPE")

End Sub

when I thought something had to go in the parenthases.  I still think something should be there, but not what I have...
Can anyone help a newbie out?
???

Thanks!
Michelle
Title: Re: Trying to create a Macro to run a report
Post by: MacGyver on February 04, 2013, 08:47:50 PM
The only thing i could think of is to try that code again with the report definition in your my docs folder.  I'm not quite positive how to run a report that's stored in the document itself.
Title: Re: Trying to create a Macro to run a report
Post by: koflynn on April 13, 2017, 11:58:44 AM
All you need to do is take out the .vrd from the code andit will work

Sub Report()

Visio.Application.Addons("VisRpt").Run ("/rptDefName=Diebold Equipment/rptOutput=EXCEL_SHAPE")

End Sub