Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access is denied (opening txt w/ notepad 1

Status
Not open for further replies.

JFRobishow

Technical User
Jun 18, 2003
87
CA
Hi everyone,

I have a small problem right now, I've a file list box on a file and I would like to be able to click on the name of the files and have them open in notepad, I have this :

Private Sub File1_Click()

Shell "Notepad.exe" & " " & File1.path, vbNormalFocus

End Sub

This is giving me an Access Denied error, while it's working fine for other file, I'm kind of lost as I don't know much about vb...any suggestions?

Thanks in advance for the reply,
 
File1.Path is the folder that contains the files visible in the file list box.

try this instead...

Code:
Private Sub File1_Click()
  Dim FileName As String

  FileName = File1.Path & "\" & File1.List(File1.ListIndex)
  Shell "Notepad.exe " & FileName, vbNormalFocus

End Sub

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
*embarassed*

lol I can't believe I didn't Debug.Print that it never came to mind but again I'm in need of sleep today :p

Thanks a bunch!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top