Question : Find and open a PDF file with Access 2009

I need to implement a routine in a command button that looks for a pdf file in a computer and opens it. Any idea of how to do it?

I can program the finding algorithm myself, but I don't know the commands or functions in access needed to access the file system, or open a PDF file. Especially FINDING a file...

Answer : Find and open a PDF file with Access 2009

I didn't know Access 2009 was released yet.

"I can program the finding algorithm myself, but I don't know the commands or functions in access needed to access the file system"
I don't understand - You can or you can't ?

To find a file, see Single File Dialog below.

To display a pdf, I would use the free Foxit Reader (http://www.foxitsoftware.com) in command line mode with the shell command.  Combining this with Single File Dialog:

With Application.FileDialog(msoFileDialogOpen)  'can also use msoFileDialogSaveAs or msoFileDialogFolderPicker
    .AllowMultiSelect = False  'allow one file only
    .Filters.Clear   'Clear "Files of type" selection
    .Filters.Add "Access Files", "*.mdb", 1  'add first "Files of type" selection
    .Filters.Add "All", "*.*", 2  'add second "Files of type" selection
    If .Show Then   'show the dialog, show returns True if something is selected
        Shell """C:\Program Files\Foxit Software\Foxit Reader\Foxit Reader.exe""" & " """ & .SelectedItems(1) & """"
    Else
        MsgBox "Nothing selected!"
    End If
End With


Single File Dialog call:

Dim strPathFileName As String
With Application.FileDialog(msoFileDialogOpen)  'can also use msoFileDialogSaveAs or msoFileDialogFolderPicker
    .AllowMultiSelect = False  'allow one file only
    .Filters.Clear   'Clear "Files of type" selection
    .Filters.Add "Access Files", "*.mdb", 1  'add first "Files of type" selection
    .Filters.Add "All", "*.*", 2  'add second "Files of type" selection
    If .Show Then   'show the dialog, show returns True if something is selected
        strPathFileName = .SelectedItems(1)   'Set the selection to strPathFileName
    Else
        MsgBox "Nothing selected!"
    End If
End With


Multi selection File Dialog call:

'Declare a variable to contain the path of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant

'Use a With...End With block to reference the FileDialog object.
With Application.FileDialog(msoFileDialogFilePicker
  .AllowMultiSelect = True      'allow Multiple Selections
  'Use the Show method to display the File Picker dialog box and return the user's action.
  If .Show = -1 Then
     'Step through each string in the FileDialogSelectedItems collection.
     For Each vrtSelectedItem In .SelectedItems
         'vrtSelectedItem is a String that contains the path of each selected item.
         'You can use any file I/O functions that you want to work with this path.
         'This example simply displays the path in a message box.
         MsgBox "The path is: " & vrtSelectedItem
     Next vrtSelectedItem
  Else
    MsgBox "Nothing selected!"
  End If
End With
Random Solutions  
 
programming4us programming4us