Avatar billede joggeren Nybegynder
05. december 2006 - 23:24 Der er 12 kommentarer og
1 løsning

Åbning af pdf fil

Jeg har lagret en pdf fil i en tabel, som OLE objekt.

Hvordan laver jeg en funktion, hvor man når man står ved denne post i en formular, kan åbne denne lagrede pdf fil?
Avatar billede terry Ekspert
06. december 2006 - 10:43 #1
I would have thought that you could just double click on the field with the OLE object in, or maybe right click and select open.

But why save the PDF in the dB? Its best if you only save the path/filename and then pen the picture when you need to,
Avatar billede terry Ekspert
07. december 2006 - 11:21 #2
do you still need help here?
Avatar billede joggeren Nybegynder
07. december 2006 - 19:05 #3
How do I create a command for opening of a link to a pdf file?
Avatar billede terry Ekspert
07. december 2006 - 19:59 #4
Place this code in a module and call using

Dim lRet as Long

lRet = ShellExecute("C:\Path\FileName.pdf")



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&

Public Function ShellExecute(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
    ShellExecute = lRet & _
                IIf(stRet = "", vbNullString, ", " & stRet)
End Function
Avatar billede terry Ekspert
07. december 2006 - 20:00 #5
thd pdf file will open in th eprogram which is associated with PDF documents, for example Adobe Acrobat
Avatar billede joggeren Nybegynder
07. december 2006 - 21:11 #6
Okay - hvordan starter jeg denne hændelse?
Avatar billede terry Ekspert
08. december 2006 - 12:17 #7
lets say you have a form which has a field containing the path+filename of the PDF document. You also have a button.
In the buttons on click event you would use somnething like.

Dim lRet as Long

lRet = ShellExecute(me.FieldWitPathFileName,1)
Avatar billede joggeren Nybegynder
09. december 2006 - 15:32 #8
Når jeg indsætter dette modul, fungerer alle andre funktioner ikke.

Hvis jeg afspiller en anden funktion, melder den fejl, og går så ind i ovenstående kode.

Måske indsætter jeg koden i modulet forkert?
Avatar billede terry Ekspert
09. december 2006 - 17:29 #9
hard to say what the problem is. Your welcom eto send me the dB if you want. I'll take a look as soon as possible

ekspertenATsanthell.dk

change AT to @
Avatar billede joggeren Nybegynder
11. december 2006 - 22:10 #10
Sendt
Avatar billede terry Ekspert
12. december 2006 - 17:50 #11
have you received the dB I sent back?
Avatar billede joggeren Nybegynder
12. december 2006 - 22:16 #12
Yes - it worked perfectly. Thanks.
Avatar billede terry Ekspert
13. december 2006 - 08:11 #13
selv tak
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester