Opening An External File

  • Thread starter Thread starter Matthew
  • Start date Start date
M

Matthew

I am trying to write what should be a fairly simple thing....

I need the user to be able to select a report thorugh drop down menus,
then an example of this is shown on the screen, I can do this using
one of J.E. McGimpsey's brilliant macros.

I would then like thbe user to be able to click a buttone and the
actual report (usualy pdf) to open, not to hard I thought........

I have a total of 80 reports all stored in the one file with sensible
names.

Can anyone help ?

Matthew
 
You need to use the shell command and specify the complete path of where the
adobe reader is located on your PC. Note the is a space between the adobe
path and the file name

Adobe = "C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe"
Shell (Adobe & " c:\temp\bell.pdf")


Adobe may be located in a different location on your PC. You may need to
search the c drive to find where adobe is located if you plan to use the
macro on other PC's.

You can use filesearch for locating the adobe reader. I'm searching the
entire c: drive. You may want to use a path like "C:\Program Files instead
of c:.


msgbox("Searching for adobe - this may take a couple of minutes")
With Application.FileSearch
.NewSearch
.LookIn = "C:\"
.SearchSubFolders = True
.Filename = "AcroRd32.exe"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
If .Execute() = 0 Then
MsgBox ("Cannot find adobe - exiting macro")
Exit Sub
Else
adobe = .FoundFiles.Item(1)

End If
End With
 
You need to use the shell command and specify the complete path of where the
adobe reader is located on your PC.  Note the is a space between the adobe
path and the file name

Adobe = "C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe"
Shell (Adobe & " c:\temp\bell.pdf")

Adobe may be located in a different location on your PC.  You may need to
search the c drive to find where adobe is located if you plan to use the
macro on other PC's.

You can use filesearch for locating the adobe reader.  I'm searching the
entire c: drive.  You may want to use a path like "C:\Program Files instead
of c:.

msgbox("Searching for adobe - this may take a couple of minutes")
With Application.FileSearch
    .NewSearch
    .LookIn = "C:\"
    .SearchSubFolders = True
    .Filename = "AcroRd32.exe"
    .MatchTextExactly = True
    .FileType = msoFileTypeAllFiles
    If .Execute() = 0 Then
       MsgBox ("Cannot find adobe - exiting macro")
       Exit Sub
    Else
       adobe = .FoundFiles.Item(1)

    End If
End With

Wowsie, I guessed it was tough.......in the end I have cheated a
little and put a 'fix' in.
Thanks for your help though all is stored away for when I run out of
ideas !!!
 
I found a better method in a posting today. Much easier to impliment

retValue = Shell("C:\Windows\explorer.exe c:\temp\test.pdf", vbNormalFocus)

the file name is in the shell and will automatically open the PDF in a
window explorer in an IE explorer type window. Don't need to find where the
adobe application is located.
 
Back
Top