ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open Text File in Excel (https://www.excelbanter.com/excel-programming/382917-open-text-file-excel.html)

Steve C

Open Text File in Excel
 
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!
--
Steve C

[email protected]

Open Text File in Excel
 
Try:

Shell "G:\Employees\Names.txt"

That should open the file in the machine's default text editor.


Mike

Open Text File in Excel
 
Sub opennotepad()
returnedvalue = Shell("C:\WINDOWS\notepad.exe \G:\Employees\Names.txt", 1)
End Sub

"Steve C" wrote:

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!
--
Steve C


Mike

Open Text File in Excel
 
oops typo

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

"Mike" wrote:

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

"Steve C" wrote:

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!
--
Steve C


Steve C

Open Text File in Excel
 
Thanks for the help!
--
Steve C


"Mike" wrote:

oops typo

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

"Mike" wrote:

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

"Steve C" wrote:

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!
--
Steve C



All times are GMT +1. The time now is 08:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com