Lookp Acrobat install location in code and assign to a variable

K

Ken

In the code below I have hard coded the path to where Acrobat is installed.
What I really need is to look up the install path via code and write it to a
variable so that the code can be computer independent.

For instance, this is where the patch is stored in the registry.
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe

Here is the code I'm using now that I need to modify.

***************************
Dim strFilePath As String
Dim strAcrobatPath As String

'set the file path for acrobat (please double check this)
strAcrobatPath = "C:\Program Files\Adobe\Acrobat 7\Acrobat\Acrobat.exe"

'set the file path for the pdf file (as shown in the textbox NomeFile)
'strFilePath = Me.NomeFile.Value
strFilePath = DLookup("[ImagesPath]", "tblOwnerInfo") & "\" &
Forms![frmDataEntry]![sbfDocuments]![DocID] & ".pdf"

'open the pdf file
Shell strAcrobatPath & " " & strFilePath
***************************

Thank you.

Ken
 
A

Albert D. Kallal

Why not just shell to the pdf file,and foget about what type of pdf viewer
the person has?
strFilePath = DLookup("[ImagesPath]", "tblOwnerInfo") & "\" &
Forms![frmDataEntry]![sbfDocuments]![DocID] & ".pdf"

Application.FollowHyperlink strFilePath


You can also launch word, excel..whatever....

Application.FollowHyperlink "C\mydata\mydoc.doc"

So, the above don't care were the application is...it just launches it.
I mean, perhaps the person is using something else (like ghostscript) to
view/open pdf files....

the above is just like as if you clicked on the document file...and the
appropriate application launches.

I don't see any real particular reason to look for, or use the actual .exe
path name to the application. and, the above can used for any doc..not only
pdf......
 
D

Douglas J. Steele

As an alternative to Albert's suggestion (which really is the way to go),
there's also the ShellExecute API that takes a full path to a file as an
argument, then starts that file up in the registered application. See
http://www.mvps.org/access/api/api0018.htm at "The Access Web" for a
complete example.
 
K

Ken

I suspected there was an easy way such as a shelling command but didn't know
how to find it. Is there some quick reference place that lists all of these
shell commands and what they're used for, without having to know their names
before hand digging through a ton of help?

I tried Helen Feddema (Access Archon) accarch148.zip (
http://www.helenfeddema.com/access.htm ) , but that involved a ton of code
and didn't work. Don't get me wrong as I appreciate her contributions and
have used them in the past before, so I'm sure it was something I was doing
or there was a some other reason when her approach should be used.

The "Application.FollowHyperlink strFilePath" works perfectly! I'm extremely
grateful.

BTW, this database will be used on multiple PC that are not networked. The
pdf files I need to access will most likely be stored on a CD or DVD and
accessed from there. I can use the path stored in a table approach as shown
below, but if the code could just grab the CD/DVD drive letter unique to
each system, that would be the better approach. Any ideas here would also
be appreciated.

Thank you.

Ken

Albert D. Kallal said:
Why not just shell to the pdf file,and foget about what type of pdf viewer
the person has?
strFilePath = DLookup("[ImagesPath]", "tblOwnerInfo") & "\" &
Forms![frmDataEntry]![sbfDocuments]![DocID] & ".pdf"

Application.FollowHyperlink strFilePath


You can also launch word, excel..whatever....

Application.FollowHyperlink "C\mydata\mydoc.doc"

So, the above don't care were the application is...it just launches it.
I mean, perhaps the person is using something else (like ghostscript) to
view/open pdf files....

the above is just like as if you clicked on the document file...and the
appropriate application launches.

I don't see any real particular reason to look for, or use the actual .exe
path name to the application. and, the above can used for any doc..not
only pdf......
 
K

Ken

Thank you for this alternative method. I will definitely keep it bookmarked.

Ken

Douglas J. Steele said:
As an alternative to Albert's suggestion (which really is the way to go),
there's also the ShellExecute API that takes a full path to a file as an
argument, then starts that file up in the registered application. See
http://www.mvps.org/access/api/api0018.htm at "The Access Web" for a
complete example.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Ken said:
In the code below I have hard coded the path to where Acrobat is
installed. What I really need is to look up the install path via code and
write it to a variable so that the code can be computer independent.

For instance, this is where the patch is stored in the registry.
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe

Here is the code I'm using now that I need to modify.

***************************
Dim strFilePath As String
Dim strAcrobatPath As String

'set the file path for acrobat (please double check this)
strAcrobatPath = "C:\Program Files\Adobe\Acrobat
7\Acrobat\Acrobat.exe"

'set the file path for the pdf file (as shown in the textbox NomeFile)
'strFilePath = Me.NomeFile.Value
strFilePath = DLookup("[ImagesPath]", "tblOwnerInfo") & "\" &
Forms![frmDataEntry]![sbfDocuments]![DocID] & ".pdf"

'open the pdf file
Shell strAcrobatPath & " " & strFilePath
***************************

Thank you.

Ken
 

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