Hyperlink to PDF

G

Guest

I have a database that stores data about properties the company owns. I have
a pdf file of a site map for each location that I want to be able to open
from the form when viewing the data for that location. On the test server
this works fine. I have the path starting with server name listing the
folder names to the filename for each pdf in the hyperlink field, and when I
click the link from the form, Acrobat opens and I see the pdf.

My problem is on the real server, when the user clicks the hyperlink,
nothing happens! If Acrobat is already open, it pulls it to the front, but
does NOT open the file. If we paste the hyperlink into windows explorer, the
pdf opens perfectly, so I know the path is correct. Both are using Access
2003. The test system does not run automatic updates from Microsoft though,
and the real one has done some updates. Could this be my problem?? and if
so, how can I get around it???

Thanks!
Susan
 
P

Paradigm

Try this funciotn, all you need to do is give it the path and filename of
the file you want to open. It will work with files of any type and use the
program on the computer regsitered for the file type to open it.


'***************Usage Examples***********************
'Open a folder: ?fHandleFile("C:\TEMP\",WIN_NORMAL)
'Call Email app: ?fHandleFile("mailto:[email protected]",WIN_NORMAL)
'Open URL: ?fHandleFile("http://home.att.net/~dashish", WIN_NORMAL)
'Handle Unknown extensions (call Open With Dialog):
' ?fHandleFile("C:\TEMP\TestThis",Win_Normal)
'Start Access instance:
' ?fHandleFile("I:\mdbs\CodeNStuff.mdb", Win_NORMAL)
'****************************************************
Private Declare Function apiShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) _
As Long
'***Error Codes***
Private Const ERROR_SUCCESS = 32&
Private Const ERROR_NO_ASSOC = 31&
Private Const ERROR_OUT_OF_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&
'#######################################################
Function fHandleFile(stFile As String, lShowHow As Long)
Dim lRet As Long, varTaskID As Variant
Dim stRet As String
'First try ShellExecute
lRet = apiShellExecute(hWndAccessApp, vbNullString, stFile,
vbNullString, vbNullString, lShowHow)

If lRet > ERROR_SUCCESS Then
stRet = vbNullString
lRet = -1
Else
Select Case lRet
Case ERROR_NO_ASSOC:
'Try the OpenWith dialog
varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL "
& stFile, WIN_NORMAL)
lRet = (varTaskID <> 0)
'stRet = "Error: No application is registered to handle this
file!"
Case ERROR_OUT_OF_MEM:
stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
Case ERROR_FILE_NOT_FOUND:
stRet = "Error: File not found. Couldn't Execute!"
Case ERROR_PATH_NOT_FOUND:
stRet = "Error: Path not found. Couldn't Execute!"
Case ERROR_BAD_FORMAT:
stRet = "Error: Bad File Format. Couldn't Execute!"
Case Else:
End Select
End If
fHandleFile = lRet & _
IIf(stRet = "", vbNullString, ", " & stRet)
End Function
'************ Code End **********
 
A

Arvin Meyer [MVP]

We would really appreciate if you would link to, instead of copying and
pasting our copyrighted content. Especially considering that it is missing
the copyright notice which is required for its use:

' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish

http://www.mvps.org/access/api/api0018.htm
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
P

Paradigm

Sorry

Arvin Meyer said:
We would really appreciate if you would link to, instead of copying and
pasting our copyrighted content. Especially considering that it is missing
the copyright notice which is required for its use:

' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish

http://www.mvps.org/access/api/api0018.htm
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access

shell32.dll,OpenAs_RunDLL
 

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