PDF opens and closes in a flash?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Good day,

I have a link in my dbase to open up a PDF document under the double click
event What happens is that
the document opens and then closes in a flash. Could anyone tell what I need
to do too fix this?

Any help would be appreciated
 
K said:
Good day,

I have a link in my dbase to open up a PDF document under the double click
event What happens is that
the document opens and then closes in a flash. Could anyone tell what I need
to do too fix this?

Any help would be appreciated
 
K:

Usually this means that the PDF file in question is corrupt in some manner.

If you want to try a different method to display our PDF, I've included a
little code below you can cut and paste into a module to either display or
print a PDF by calling acg_DisplayPDF and supplying a full file path as a
test string to the function.
--
SA
ACG Soft
http://www.groupacg.com

----------begin code----------
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias
"RegOpenKeyExA" _
(ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long,
_
ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegQueryValueExString Lib "advapi32.dll" Alias
"RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As
Long, _
lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long)
As Long
Private Function acg_GetAcro(bType As Byte) As Variant
'By ACG Soft - www.groupacg.com
'bType as 1=Find Acrobat Type - Result: 0= Not Installed, 1=Full, 2=Reader
'bType as 2= Get Acrobat or Reader Path
Dim dwReturn&, hKey&, strData$, dwType&, strPath$
Const HKEY_LOCAL_MACHINE = &H80000002: Const REG_SZ = 1
Const REG_KEY_READ = &H20019: Const intBuffSZ = 260
Const ERROR_NONE = 0

dwReturn = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe", 0,
REG_KEY_READ, hKey)
If dwReturn = ERROR_NONE Then
If bType = 1 Then
acg_GetAcro = 1
RegCloseKey (hKey)
Else
strData = Space(intBuffSZ)
dwReturn = RegQueryValueExString(hKey, "Path", 0&, dwType, strData,
Len(strData))
If dwReturn = ERROR_NONE Then
strPath = left(strData, InStr(strData, Chr(0)) - 1)
If right(strPath, 1) <> "\" Then strPath = strPath & "\"
acg_GetAcro = strPath & "Acrobat.exe"
Else
acg_GetAcro = ""
End If
RegCloseKey (hKey)
End If
Else
dwReturn = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe", 0&,
REG_KEY_READ, hKey)
If dwReturn = ERROR_NONE Then
If bType = 1 Then
acg_GetAcro = 2
RegCloseKey (hKey)
Else
strData = Space(intBuffSZ)
dwReturn = RegQueryValueExString(hKey, "Path", 0&, dwType,
strData, Len(strData))
If dwReturn = ERROR_NONE Then
strPath = left(strData, InStr(strData, Chr(0)) - 1)
If right(strPath, 1) <> "\" Then strPath = strPath & "\"
acg_GetAcro = strPath & "AcroRd32.exe"
Else
acg_GetAcro = ""
End If
RegCloseKey (hKey)
End If
Else
If bType = 1 Then
acg_GetAcro = 0
Else
acg_GetAcro = ""
End If
End If
End If
End Function

Public Sub acg_DisplayPDF(FullFilePath As String, Optional bAction As Byte =
1, Optional boolCloseAfterPrint As Boolean = False)
'By ACG Soft - www.groupacg.com
'bAction: 1 = Display, 2 = Print
On Error Resume Next
Dim strAcroPath$, dblReturn As Double
Dim varChannel As Variant
If Len(Dir(FullFilePath)) < 1 Then
'File not found
MsgBox "The target PDF file doesn't exist", 16
Exit Sub
End If
dblReturn = acg_GetAcro(1)
If dblReturn <> 0 Then
strAcroPath = acg_GetAcro(2)
If bAction = 1 Then
strAcroPath = strAcroPath & " " & FullFilePath
dblReturn = Shell(strAcroPath, vbNormalFocus)
DoEvents
ElseIf bAction = 2 Then
strAcroPath = strAcroPath & " /p /h" & " " & FullFilePath
dblReturn = Shell(strAcroPath, vbNormalFocus)
DoEvents
If boolCloseAfterPrint = True Then
'use a little real old technology to easily control Acrobat
varChannel = DDEInitiate("acroview", "control")
DDEExecute varChannel, "[AppExit]"
End If
End If
Else
MsgBox "Neither Adobe Acrobat nor Adobe Acrobat Reader are installed on
this computer.", 16
Exit Sub
End If

End Sub
---------------end code------------------
 
Back
Top