Opening a PDF from Access - Initialize Problem

velcrowe

Registered User.
Local time
Today, 10:45
Joined
Apr 26, 2006
Messages
86
I have a hyperlink field that allows my users to click the link and see the actual order (hardcopy) they submitted. When I set the hyperlink to open a .jpeg it works but I am using too much memory. Also, the users use various software to open .jpegs so I need to streamline the process to Adobe Acrobat. I started scanning the orders and setting the links to the .pdf file and it's not working. From inside Access, it works like Adobe Acrobat is going to open but then it disappears. Is there anyone who can help me fix this. I really need to open pdfs from links inside Access. Thank you
 
I have a hyperlink field that allows my users to click the link and see the actual order (hardcopy) they submitted. When I set the hyperlink to open a .jpeg it works but I am using too much memory. Also, the users use various software to open .jpegs so I need to streamline the process to Adobe Acrobat. I started scanning the orders and setting the links to the .pdf file and it's not working. From inside Access, it works like Adobe Acrobat is going to open but then it disappears. Is there anyone who can help me fix this. I really need to open pdfs from links inside Access. Thank you

I have found this you will have to click the hyperlink multiple times to get it to finally open a PDF.

I use ShellExec() and it works great with PDFs.
 
Just in case you need some code for ShellExec:

Code:
'************ Code Start **********
' 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
'
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

'***App Window Constants***
Public Const WIN_NORMAL = 1         'Open Normal
Public Const WIN_MAX = 3            'Open Maximized
Public Const WIN_MIN = 2            'Open Minimized

'***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&

'***************Usage Examples***********************
'Open a folder:     ?fHandleFile("C:\TEMP\",WIN_NORMAL)
'Call Email app:    ?fHandleFile("mailto:dash10@hotmail.com",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)
'****************************************************

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)
            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 **********
 
I don't understand. Where would I place ShellExec() so that all the hyperlinks in my table would open the corresponding .pdf file? Would I create a module? Thank you for you help
 
I don't understand. Where would I place ShellExec() so that all the hyperlinks in my table would open the corresponding .pdf file? Would I create a module? Thank you for you help

Oh..:eek:... so you are using a hyperlink data type field in a table. I find these are only good for web page URLs and nothing else. I have stopped using them. I find them to be very difficult to work with and not worth all the effort (extra coding => cost => $$$ ) required.


About the ShellExec(): yes, you would put this code in a standard code module.

I am not sure how to use the ShellExec() with a hyperlink field data type. I normally use it with a text data type field.
 

Users who are viewing this thread

Back
Top Bottom