Open Text File in Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a text file called Names.txt (stored at G:\Employees\Names.txt) that I
use to populate a combo box in an Excel form. The last choice in this list is
"-Name Not Listed-". I instruct the users of the form to choose this if the
desired employee name is not listed and click OK.

Upon clicking OK, my code currently checks to see if that choice was made.
If it is, I want the Names.txt text file to open (in Notepad) so that they
can add the name so it's available next time they use the form. I'm
struggling with the code that will open the file in Notepad. Thanks!
 
Try:

Shell "G:\Employees\Names.txt"

That should open the file in the machine's default text editor.
 
Sub opennotepad()
returnedvalue = Shell("C:\WINDOWS\notepad.exe \G:\Employees\Names.txt", 1)
End Sub
 
oops typo

returnedvalue = Shell("C:\WINDOWS\notepad.exe G:\Employees\Names.txt", 1)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top