How to Tell Whether "Save as PDF or XPS" Add-On Is Installed

G

Guest

I have an application that can run under either Access 2003 or 2007, but I
want to disable the "Write PDF" button I've placed on a form when the "Save
as PDF or XPS" add-on is not installed.

My first thought was to check for the existence of the new acFormatPDF
constant, but referring to a constant that doesn't exist generates an
untrappable compile-time error. I next thought that I'd try trapping an
error in something like Eval("acFormatPDF"), but Eval can't evaluate to an
Access system object.

Registry entries for "Save as PDF or XPS" are all under Office 12, so that
looking for them will break the application under Office 13.

Is there some way to see whether acFormatPDF exists or is contained within
Access.Constants? Is there some other way within Access itself to determine
whether the add-in is installed?

Thanks in advance for any help.
 
R

RoyVidar

nospam said:
I have an application that can run under either Access 2003 or 2007,
but I want to disable the "Write PDF" button I've placed on a form
when the "Save as PDF or XPS" add-on is not installed.

My first thought was to check for the existence of the new
acFormatPDF constant, but referring to a constant that doesn't exist
generates an untrappable compile-time error. I next thought that I'd
try trapping an error in something like Eval("acFormatPDF"), but Eval
can't evaluate to an Access system object.

Registry entries for "Save as PDF or XPS" are all under Office 12, so
that looking for them will break the application under Office 13.

Is there some way to see whether acFormatPDF exists or is contained
within Access.Constants? Is there some other way within Access
itself to determine whether the add-in is installed?

Thanks in advance for any help.

Interesting question!

I think I may have one way, but not very elegant. If you use the
literal value, in stead of the constant, you may get a run-time error
which you can trap for.

?acFormatPDF -> "PDF Format (*.pdf)"

DoCmd.OutputTo, acOutputReport, "TheReport", "PDF Format (*.pdf)", _
"c:\TheReport.pdf", False

Should probably give 2282 when executed, but no compile error.

There are probably more elegant solutions out there (which I'd like
to know, too ;-)

Perhaps better, would be to install something that works on both
versions? I use Stephen Lebans ReportToPDF

http://www.lebans.com/reporttopdf.htm

on all versions 2000 through 2007 (even though he says 2000-2003).
 
G

Guest

Thanks for a clever suggestion. In 2007, submitting an invalid character
string raises a run-time 2282, so I presume that the same would obtain in
2003. The OutputTo method in 2003 accepts one fewer argument, however (no
output quality), so I'd need to have two different OutputTo statements,
executed based on the version running--not an impossibility. This approach,
however, does not readily lend itself to disabling a form control a priori.

What I think I'm going to do is determine the location of the target
machine's Program Files folder and Access version and use Dir to check for
the existence of the DLL. There's no guarantee that it will work going
forward, but it seems OK for now.

Public Function HasPDFAddOn() As Boolean
' Quick and dirty check for presence of "Save as PDF or XPS" add-on
' Note that the name of "Program Files" folder may differ with Windows
version (and country?)
Dim strPF As String, i As Integer, strVer As String, strPDF As String
strPF = References("access").FullPath
i = InStr(strPF, "\")
i = InStr(i + 1, strPF, "\")
strPF = Left(strPF, i)
strVer = Application.Version
i = InStr(strVer, ".")
i = IIf(i = 0, Len(strVer), strVer)
strVer = Left(strVer, InStr(strVer, ".") - 1)
strPDF = strPF & "Common Files\Microsoft Shared\OFFICE" & strVer &
"\EXP_PDF.DLL"
HasPDFAddOn = (Len(Dir(strPDF)) <> 0)
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top