A few words of thanks would be greatly appreciated.

Excel - A macro to open file with Notepad


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")

A few words of thanks would be greatly appreciated.

Ask a question
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team


Published by . Latest update on by aakai1056.

This document, titled "Excel - A macro to open file with Notepad," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).