Excel - A macro to open file with Notepad

December 2016


I would like to open a file with Notepad. I have a small macro for this purpose but the problem is that the code opens my file with Word , instead of Notepad.

Sub bloc() 
Dim s As Variant 
Dim i As Integer 

s = Shell("C:\Program Files\Microsoft Office\Office12\WINWORD.EXE C:\Users\Username\Desktop\filename.txt") 


Replace the WINWORD.EXE by notepad.exe:

s = Shell("C:\Program Files\Microsoft Office\Office12\notepad.exe C:\Users\Username\Desktop\filename.txt")

Related :

This document entitled « Excel - A macro to open file with Notepad » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.