Jaymond Flurrie
Well-known Member
- Joined
- Sep 22, 2008
- Messages
- 898
- Office Version
-
- 2016
So, I have a button that says "Open Notepad". I have a textbox txtIni.Text that might have filepath, like "c:\ini.txt". If "Open Notepad" button is pressed, program should check that does that file exists, if it does, then it opens the notepad and loads that file. If it doesn't exists, then it should just load the notepad.
I tried this
I think there's something wrong with that "Shell ("notepad.exe " & txtIni.Text & ", 1")" line.
That FileOrDirExists() function checks whether the file exists or not.
I tried this
Code:
Private Sub btnNotePad_Click()
Dim retval As Variant
If FileOrDirExists(txtIni.Text) Then
If Not txtIni.Text = "" Then
retval = Shell("notepad.exe " & txtIni.Text & ", 1")
Else
retval = Shell("notepad.exe", 1)
End If
Else
retval = Shell("notepad.exe", 1)
End If
End Sub
That FileOrDirExists() function checks whether the file exists or not.
Last edited: