Hello,
I've been successful in creating and running a custom shape report from a VBA macro, it fits my needs nicely.
Now, I'd like to further automate this by calling the macro from a Powershell script. Unfortunately, I'm presented with the dialog box to choose the output format and filename despite the fact the macro already specifies this as such:
Public Sub RunShapeReport()
Application.Documents.OpenEx "C:\Users\me\Desktop\visio\my_drawing.vsd", visOpenRO
SendKeys "{Enter}", True
ComStr = "/rptDefName=C:\Users\me\Desktop\visio\ReportDefinition_1.vrd /rptOutput=XML /rptOutputFilename=C:\Users\me\Desktop\visio\Report_1.xml /rptSilent=True"
Visio.Application.Addons("VisRpt").Run (ComStr)
Application.ActiveDocument.Close
End Sub
The powershell script is rather simple as well:
$VD = new-object -comobject Visio.Application
$VD.Visible = $false
$doc = $VD.Documents.open("C:\Users\me\Desktop\visio\visShapeReport.vsdm")
$VD.ActiveDocument.ExecuteLine("RunShapeReport")
$VD.quit()
Has anyone been able to achieve something like this before?
Thanks in advance!
Have you tried calling the macro from VBA?
I guess it will behave the same.
BTW, I've seen code for running reports, that doesn't require sendkeys. Maybe you could check this.
I googled "visio report vba site:visguy.com", there were quite some posts.
Rgds,
Y.
Oddly enough, it just started working without any changes. The macro always worked when run directly from VBA.
Thanks for the reply, though!
I'll update this post with the full solution once it's complete for further reference.