PDA

Click to See Complete Forum and Search --> : open a file?


dries
Dec 4th, 2001, 07:58 AM
How do I open a file using APIs?

Thanks

dries

Matthew Gates
Dec 4th, 2001, 08:45 AM
Use the ShellExecute API function.


Private 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

Private Sub OpenFile(sFile As String)
ShellExecute Me.hwnd, vbNullString, sFile, vbNullString, vbNullString, 1
End Sub

Private Sub Command1_Click()
Call OpenFile("C:\MyFile.txt")
End Sub