open text file

birdman

Board Regular
Joined
Oct 11, 2005
Messages
187
does anyone know the code to open a text file when a commandbutton on a userform is clicked?? the file extension is

C:\Program Files\Process Files\Help File.txt

so when the commandbutton is clicked, this text file will open.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
does anyone know how to open a text file using notepad when clicking on a commandbutton?
 
Upvote 0
call shell ("notepad.exe",7)

that will load up notepad bu tnot sure how to pass the parameter of the file yet
 
Upvote 0
on this subject, when i create the help/readme text file to be opened with notepad, how can i make the notepad file uneditable similar to the way most readme files are????
 
Upvote 0
Birdman - Here is one way or you could use ShellExecute as mentioned in that other post.

Code:
      Filestring = "notepad.exe " & myfile
      Response = MsgBox("Data File Created" & Chr$(13) & Chr$(10) & _
            "File = " & myfile & Chr$(13) & Chr$(10) & _
            "Would you like to edit the file now?", vbYesNo, "ABC, Inc.")
      If Response = vbYes Then
             RunIt = Shell(Filestring, 1)
      End If
myfile would = "C:\Program Files\Process Files\Help File.txt" in your case.

OR you could just put the text of what you want to show in a textbox of a userform, so that when they click the button, it will display the info. Put an OK button on the form to enable them to close it. That would make it uneditable but also allow them to see the "readme" info.

Just an idea. Good luck.
 
Upvote 0

Forum statistics

Threads
1,206,754
Messages
6,074,750
Members
446,083
Latest member
kfunt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top