Kamis, 16 Agustus 2012

RE: [MS_AccessPros] Tip of the Week: Coding for PDF in 2003 and 2010

 

You're genius Bill.

Liz Ravenwood
Programmer/Analyst
Super First Class Products
B/E Aerospace
O: 1.520.239.4808
www.beaerospace.com

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Bill Mosca
Sent: Thursday, August 16, 2012 11:49 AM
To: MS_Access_Pros
Subject: [MS_AccessPros] Tip of the Week: Coding for PDF in 2003 and 2010

Level: Intermediate (VBA code)

Hi all

It's been way too long since my last TOW, but when I discovered something I think is important I thought I should post.

Scenario:

I developed an Access 2002-2003 application that takes advantage of Stephen Lebans' PDF writer for reports (http://www.lebans.com/reporttopdf.htm) and you now have users with Access 2010 running on Windows 7. Guess what. All portrait reports won't write to PDF with the DLLs Mr. Lebans uses. They get flipped to landscape and the bottom third of each page is cut off. And What's even sadder is the new DynaPDF DLL is no longer free.

Solution:

You can code an If block to take advantage of the built-in PDF writer in Access 2010. But not directly. This line will not compile in 2003 MDB.

DoCmd.OutputTo acOutputReport, strRptName, _

acFormatPDF, _

strFileName, bolOpenViewer

acFormatPDF is not a known enumeration in 2003. When I first attempted this and found out it would not compile I went to my 2010 machine to find the Long value of acFormatPDF. I figured I could just use the value and the code would compile.

What I found was rather new to me. The value was not a Long. It was a string.
The string was:

"PDF Format (*.pdf)"

Hey! That's the same structure that you'd use for a file type filter in a common dialog box. So I wrote it up this way:

DoCmd.OutputTo acOutputReport, strRptName, _

"PDF Format (*.pdf)", _

strFileName, bolOpenViewer

And lo and behold, it compiled in my MDB.

Now I had to just write the If block so it would work if the MDB (or MDE) was opened in Access 2010 on Windows 7. This did the trick:

If SysCmd(acSysCmdAccessVer) >= 14# Then

DoCmd.OutputTo acOutputReport, strRptName, _

"PDF Format (*.pdf)", _

strFileName, bolOpenViewer

Else

Call ConvertReportToPDF(strRptName, , strFileName, _

False, bolOpenViewer)

End If

I hope you find this useful. Feel free to comment.

Regards,
Bill Mosca,
Founder, MS_Access_Professionals
That'll do IT <http://thatlldoit.com/> http://thatlldoit.com MS Access MVP

<https://mvp.support.microsoft.com/profile=C4D9F5E7-BB03-4291-B816-64270730881E>
https://mvp.support.microsoft.com/profile=C4D9F5E7-BB03-4291-B816-64270730881E

My Nothing-to-do-with Access blog

<http://wrmosca.wordpress.com> http://wrmosca.wordpress.com

[Non-text portions of this message have been removed]

------------------------------------

Yahoo! Groups Links

This email (and all attachments) is for the sole use of the intended recipient(s) and may contain privileged and/or proprietary information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar