Kamis, 16 Agustus 2012

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

 

Back in the days when Access 2.0 was the best thing scince sliced bread, the ExportformatName was a string which represented the name of a Section in the INI.

With the move to Registry settings in later Access versions, Microsoft had to keep the type to remain compatible.

I had two strange effects from this which, at that time, I put down to the german Versions of Access. For some reason, Access 2000 was not able to output acFormatHTML, defined as "HTML (*.html)" but would work if I used my own string constant defined as "HTML (*.htm; *.html)" which is how the filter was defined in the registry.

Twelve years later I am now reminded of this and I wondered if anyone else had this problem?

Yours,
Andrew

--- In MS_Access_Professionals@yahoogroups.com, "Bill Mosca" <wrmosca@...> wrote:
>
> 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]
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar