Re: OutputTo a Report

From: SA (~fake.address_at_nspm.com)
Date: 03/16/04


Date: Tue, 16 Mar 2004 08:55:03 -0500

Nadia:

1.) Reports are not "active" documents; so if you had the name of the pdf
document displayed on the report that was the result of your QBF, the user
can't click on it in the report to launch Adobe Acrobat or Acrobat reader
and display the target PDF file.

2.) Forms on the other hand will respond to user mouse clicks etc, so if
your query by form displays in a field the PDF document and its associated
path (e.g. c:\some directory\pdf files\target pdf file.pdf) then you could,
through use a of a bit of code launch the appropriate application and open
the file. However, this takes a bit of Visual Basic code to do. Listed
below is code that you can place in a general module in your database that
will find the current install of Acrobat and launch it and open a target PDF
file.

In your form, assuming again you'd display the path to a PDF file, then set
the double click event for the control that displays the path to an event
procedure and in the event procedure add code like this that calls the
functions below:

Dim boolReturn as boolean
boolReturn = DisplayPDF(Me!NameOfControlWithPathToPDFFile)

-- 
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg
====== Begin Code - Cut and Past into a General Module ===========
'General Module Declarations
Option Compare Database
Option Explicit
Private Declare Function RegCloseKey Lib _
    "advapi32.dll" (ByVal hKey As Long) As Long
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 Function acg_GetAcro() As String
'By ACG Soft
'http://ourworld.compuserve.com/homepages/attac-cg
Dim dwReturn&, hKey&, strData$, dwType&
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
    strData = Space(intBuffSZ)
    dwReturn = RegQueryValueExString(hKey, "Path", 0&, _
        dwType, strData, Len(strData))
    If dwReturn = ERROR_NONE Then
        acg_GetAcro = left(strData, _
            InStr(strData, Chr(0)) - 1) & "Acrobat.exe"
    Else
        acg_GetAcro = ""
    End If
    RegCloseKey (hKey)
Else
    dwReturn = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
        "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe",
_
        0&, REG_KEY_READ, hKey)
    If dwReturn = ERROR_NONE Then
        strData = Space(intBuffSZ)
        dwReturn = RegQueryValueExString(hKey, "Path", 0&, _
            dwType, strData, Len(strData))
        If dwReturn = ERROR_NONE Then
            acg_GetAcro = left(strData, _
                InStr(strData, Chr(0)) - 1) & "AcroRd32.exe"
        Else
            acg_GetAcro = ""
        End If
        RegCloseKey (hKey)
    End If
End If
End Function
Public Function DisplayPDF(strTargetPDF As String) As Boolean
'By ACG Soft
'http://ourworld.compuserve.com/homepages/attac-cg
On Error Resume Next
Dim strAcroPath As String, dwReturn As Long
DisplayPDF = False
If Len(Dir(strTargetPDF)) < 1 Then
    'File not found
    MsgBox "The target PDF file doesn't exist", 16
    Exit Sub
End If
strAcroPath = acg_GetAcro()
If Len(strAcroPath) > 0 Then
    strAcroPath = strAcroPath & " " & strTargetPDF
    dwReturn = Shell(strAcroPath, vbNormalFocus)
    DoEvents
    DisplayPDF = True
Else
    MsgBox "Neither Adobe Acrobat or Acrobat Reader is installed on this
computer", 16
End If
End Function
=========End Code ================
"Nadia" <anonymous@discussions.microsoft.com> wrote in message
news:BF06EABE-DA59-4A48-B5C1-D588487D3A82@microsoft.com...
> Hi...I've set up a form to perform a query, and now I'm trying to improve
the user-friendliness of the QBF output.  I'd like the results of the query
to be output to a report. because I have some OLE objects that need to be
accessed from the results (i.e.  the OLE objects are journal articles in pdf
format, that the user searches for using the QBF, and I want them to be able
to open the OLE object right from the results of the QBF).  I've tried using
the OutputTo Macro, but I can't get it to work.  This is my first experience
with computer programming...any help or advice would be appreciated!


Relevant Pages

  • Re: PDF opens and closes in a flash?
    ... Usually this means that the PDF file in question is corrupt in some manner. ... (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As ... Dim dwReturn&, hKey&, strData$, dwType&, strPath$ ...
    (microsoft.public.access.reports)
  • Re: pdf in java Viewing... Not a good experience
    ... > BUT I need to know the external pdf viewers name ... This code is austensibly to open a url in a browser, but on Windows it will ... static class to display a URL in the system browser. ...
    (comp.lang.java.gui)
  • Re: Embedding a PDF OLE object in PowerPoint 2003
    ... I am an Access programmer and i want to display PDF documents created in my ... Access application which display custom made graphs in a powerPoint slide. ... Dim ppPres As PowerPoint.Presentation ...
    (microsoft.public.powerpoint)
  • Tomcat Incompatibility with IE6/Adobe Reader 6.0.1
    ... When we try to display a PDF file via ... IE launches the Adobe Acrobat Reader 6 Plugin ... should have been displayed in the IE browser window. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: How to kill auto-sizing of PDF or JPG attachments?
    ... For me it is very important to see exactly that what I want to send or get, because I am used to send messages as PDF, so that the receiver gets exactly the layout I did, and that he can print exactly this! ... Regarding the size of the display, this is simply dictated by the size ... I want to use PDF, because I can do an exact layout for my newsletters! ... But what about other users of Entourage 2008 or Enourage for Windows - they will have the same problem, when they receive a PDF-Newsletter from me ?!?!? ...
    (microsoft.public.mac.office.entourage)