Excel Hints

Results 1 to 2 of 2

Thread: Open text file from Word VBA using Shell Command in Win 7

  1. #1

    Open text file from Word VBA using Shell Command in Win 7

    I want to open a text file using Notepad++ when a user presses a button on a user form.
    The following worked fine in XP, but gives the error "file not found" under Windows 7. I cant find a simple answer on how to open a text file from VBA in Windows 7 . Can anybody help please? is the Shell command no longer valid in Win 7?
    [vba]


    Private Sub Btn_Edit_Settings_Click()

    dim striniFileName As String

    FileName = "c:\Settings.txt"

    Shell "C:\Program Files (x86)\Notepad++.exe" & FileName, vbMaximizedFocus
    [/vba]

  2. #2
    "I cant find a simple answer on how to open a text file from VBA in Windows 7 ."

    "is the Shell command no longer valid in Win 7?"

    Opening a file using VBA and Shell has not changed in Win 7.

    Perhaps the issue is the location of Notepad ++.exe. File locations ARE different in Win 7, from XP...thus "file not found". Have you tried actually looking for it?

Posting Permissions

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