I was looking to do this the other day. Found this code that uses ADO stream. Need to have an ADO reference in the project (ADO 2.5+ I believe). Combined with Dev Ashish's apiShellExecute code, you can load files to an OLE/BLOB field, detach them and then launch them with the proper ap. Good luck.
Public Function WriteToFile(rs As ADODB.Recordset, str_full_path As String) As Boolean
On Error GoTo Er
Dim fds As ADODB.Stream
WriteToFile = False
Set fds = New ADODB.Stream
fds.Type = adTypeBinary
fds.Open
'get data from field in current record
fds.Write rs!OLE_FIELD
fds.SaveToFile str_full_path, adSaveCreateOverWrite
WriteToFile = True
Done:
fds.Close
Set fds = Nothing
Exit Function
Er:
Select Case Err.Number
Case 3004: ' file is in use!
MsgBox "File is either already in use or it's file permissions are incorrect. Check the path or the file may be in use.", vbExclamation, "WriteToFile()"
Case Else:
'Unexpected, fail with message box
MsgBox "Error # " & Err.Number & "--" & Error, vbCritical, "WriteToFile()"
End Select
Resume Done
End Function
Public Function ReadFromFile(rs As ADODB.Recordset, str_full_path As String)
On Error GoTo Er
Dim fds As ADODB.Stream
ReadFromFile = False
Set fds = New ADODB.Stream
'Make it a binary type
fds.Type = adTypeBinary
'Open the stream
fds.Open
'
'*** Read the binary file into the stream buffer ***
'
fds.LoadFromFile str_full_path
' save binary data into Field of current record
rs!OLE_FIELD = fds.Read
rs.Update
ReadFromFile = True
Done:
fds.Close
Set fds = Nothing
Exit Function
Er:
Select Case Err.Number
Case 55
Close
Resume
Case 3002
MsgBox "Could not read file (" & str_full_path & ") , check the path or the file may be in use."
Case Else:
'Unexpected, fail with message box
MsgBox "Error # " & Err.Number & "--" & Error, vbCritical, "ReadFromFile()"
End Select
Resume Done
End Function