Powershell Interaction with Access 2007, how to Save Report as PDF?
I have an access database and a report in that database. I am using the access.application comobject to gain access to access, i.e.
$db = New-Object -ComObject Access.Application
$db.OpenCurrentDatabase("foo.accdb")
This works fine. However, as suggested in another similar question I am unable to get the report out of the db by using the DoCmd.OutputTo method.
$db.DoCmd.OutputTo(3,"The_Report","acFormatPDF","C:\The_Report.PDF")
When I execute that above command, and error returns stating that:
Exception calling "OutputTo" with "4" argument(s): 'The format in which you are attempting to output the current object is not available."
I have ensured that the "save to pdf" add-on is开发者_开发百科 installed. Beyond that, I am unable to figure out what is stopping this object from being output in the requested format. Am I missing something?
acFormatPDF is a constant, so putting the constant name in quotes seems wrong. I tried without the quotes, but Powershell doesn't appear to recognize the constant. So I tried the string value for that constant, in quotes, and it worked.
I'm basically lost with this Powershell thing, but suggest you try:
$db.DoCmd.OutputTo(3,"The_Report","PDF Format (*.pdf)","C:\The_Report.PDF")
精彩评论