Results 1 to 5 of 5

Thread: Open Notepad from Excel

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Jul 2006
    Posts
    3

    Open Notepad from Excel

    Hello, new to this forum, but figured somebody here would be of help. I have written an Excel workbook and VBA file to manage inventory for the company I work for, I will be leaving this company in a few weeks and needed to leave some documentation/help files/how to on it so that the person who takes over my position can continue to use this file. So here's my question, I want to link to this file in my excel file (create a Command Button that when clicked will open this help file in Notepad). This help file is a .txt file, which I know I can open in excel but the formatting is shot when opened in Excel, does anyone know a way that VBA can open an external application like notepad? Thanks in advance. Ben

  2. #2
    Banned
    Join Date
    Apr 2002
    Posts
    108
    The shell function should do it:

    Dim RetVal
    RetVal = Shell("C:\WINDOWS\notepad.exe", 1)

    2nd argument is window style - look up shell in the Help file for details.

  3. #3
    Junior Member
    Join Date
    Jul 2006
    Posts
    3
    Can I open a specific file say C:\myfile.txt in Notepad?

    I tried Shell("C:\myfile.txt", 1) and it throws an error.
    Thanks

  4. #4
    Banned
    Join Date
    Apr 2002
    Posts
    108
    I'd be more inclined to try something along the lines of:

    RetVal = Shell("C:\WINDOWS\notepad.exe C:\myfile.txt", 1)

  5. #5
    Junior Member
    Join Date
    Jul 2006
    Posts
    3
    Thanks, that did exactly what I wanted it to do.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •