[RESOLVED] Opening txt file with notepad
Okay i have a combo box (categories), a textbox (AddNewCategory)
and a button (add2)
The user types in a file name then clicks the button Add2 then that goes to the categories(combobox). Then i want it to be opened in notepad right after its been clicked ( feel free to take the sleep out) I use this code below to do it except when opening Notepad it wont work.
Code:
Private Sub Add2_Click()
Dim fso As New FileSystemObject
Dim Apath As String
Dim Spath As String
Apath = App.Path
Categories.AddItem (AddNewCategory.Text)
fso.CreateTextFile (AddNewCategory.Text & ".txt")
Spath = Apath & "\" & AddNewCategory.Text & ".txt"
Sleep 1000
Shell "Notepad" Spath, vbNormalFocus
End Sub
please help!
thanks in advance
Re: Opening txt file with notepad
You need a space after the "notepad" and that is if SPath is correct of course:
Code:
Shell "Notepad " Spath, vbNormalFocus
Re: Opening txt file with notepad
That didnt work. Spath is correct. "End of statement" is the error.
Re: Opening txt file with notepad
It wouldn't work if your file is invalid.
What is the value of SPath? Can you open file manually?
Re: Opening txt file with notepad
Re: Opening txt file with notepad
Aaaah! LOL :lol: Thanks DR.
Esand15, replace what you have with this - again, assuming SPath is correct:
Code:
Shell "Notepad " & Spath, vbNormalFocus
Sorry about that. :blush:
Re: Opening txt file with notepad
Weird, i tried that early and it didn't work... but now it does. i gues Spath was incorrect the first time i tried. Thanks!
Re: [RESOLVED] Opening txt file with notepad