Jumat, 17 Agustus 2012

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

 

A.D.

Thanks. I appreciate your opinion as always.

Bill

--- In MS_Access_Professionals@yahoogroups.com, "A.D. Tejpal" <adtp@...> wrote:
>
> That is a great tip Bill! Thanks for kindly sharing.
>
> No doubt, it would be of immense help to access community.
>
> Best wishes,
> A.D. Tejpal
> ------------
>
> ----- Original Message -----
> From: Bill Mosca
> To: MS_Access_Pros
> Sent: Friday, August 17, 2012 00:18
> 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
>
> [Non-text portions of this message have been removed]
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar