Open Notepad from Excel

kersi01 used Ask the Experts™
I want a button on an Excel spreadsheet that will open an application (Notepad) with the file that is named in a cell in the spreadsheet.

So, the user enters a file name in the cell, presses the button, and Notepad starts with the file open.

Can anyone help me??
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

I have the following in Cell A1 - C:\Stuff\Test.txt

I have embeded a button on the form and put the following onto it.

Private Sub CommandButton1_Click()
Dim lngResult As Long

lngResult = Shell("notepad " & Sheets("sheet1").Cells(1, 1).Value)

End Sub

Is this what you want?
add a button to Excel Sheet,new and assign Micro "Command1_Click()"

Sub Command1_Click()
    Shell "Notepad.exe " & Sheet1.Cells(1, 1)
End Sub


What I need is a spreadsheet where column A has file names and column B has buttons.  When a button is pressed it opens the file with the relevant name.

Sorry if I am being a bit dumb, I am not familiar with VB.

The examples given seem to only work with one file name, if I add more buttons they all open the same file (the one in A1).

the values in the cells(1,1) part of the statements relate to row 1 column 1 so change these values as required.  

so the next button would have
Sheets("sheet1").Cells(2, 1).Value

and so on


Very quick response - THANKS!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial