5
Contributors
5
Replies
13
Views
4 Years
Discussion Span
Last Post by AndreRet
0

it's simple

Open App.Path & "/file name" For Input as #1

"file name" is your name of file

you mast have BackSlash before file name

0

No no guyz.... I literally want the file to be opened in windows when I click the button.

1

What you want to do is somewhat difficult with the native functions in VB6. Using the windows api functions however are much more flexible. Here's an example to open a text file just by passing the path to the file. You should be able to adapt it to your needs.

Option Explicit
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

Const SW_SHOW = 5

Private Sub Command1_Click()
    Dim Filename, MyPath As String
    Filename = "test.txt"
    MyPath = App.Path & "\" & Filename
    ShellExecute hwnd, "open", MyPath, vbNullString, App.Path, SW_SHOW
End Sub

Edited by tinstaafl

Votes + Comments
Perfect
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.