Rhys no problem,
Your looking for a file open dialog to select the file for storing in the database, and for displaying the file there is a Windows API call you can use thats like a double click in explorer.
The file open dialog... this code doesn't take into consideration the user pressing cancel.
Public Sub FileOpen()
Dim dlgOpen As FileDialog Set dlgOpen = Application.FileDialog(msoFileDialogOpen)
'the file open can work with multiple file selections or with single file selections With dlgOpen .AllowMultiSelect = False .Show End With
'with both singular and multiple selections you have an array 'with singular selections there is only ever one item in the array MsgBox dlgOpen.SelectedItems(1)
End Sub
To open any file in it's registered program copy the code below into a module and from anywhere in your code call OpenFile passing in the full path to the file you want to open. PDF's will open in Acrobat, Doc's in Word, and so on.
Public Declare Function ShellExecute 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
Public Sub OpenFile(file As String) On Error GoTo OpenFile_Err 'open the document in whatever application it requires ShellExecute 0, "open", file, vbNullString, vbNullString, vbNormalFocus Exit Sub OpenFile_Err: MsgBox "An unexpected error has occurred.", vbOKOnly + vbCritical, "Error Conditon in Opening File" End Sub
www.dsmyth.net/blog |