Trying to create a Macro to run a report

Started by Michelle, January 22, 2013, 07:58:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Michelle

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

MacGyver

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")

Michelle

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

MacGyver

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.

koflynn

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