admin 管理员组

文章数量: 1086019

I wrote a vba that takes data from the spreadsheet and creates a .txt file with it. Later i prompt the user to ask if the filed should be viewed. I wanted to give the option of Notepad as well as Notepad++ but with Notepad++ there is a problem.

Just in case I will add that I use to open the file.

EditorFP = Cells(8, 39).Value
If Left(EditorFP, 2) = "1." Then
    EditorFP = Replace(EditorFP, "1. Notepad ~ ", "") & " " & Addr & FileN
ElseIf Left(EditorFP, 2) = "2." Then
    EditorFP = Replace(EditorFP, "2. Notepad++ ~ ", "") & " " & Addr & FileN
Else
End If

         If MsgBox("Open with Notepad++?", vbYesNo) = vbYes Then
            Call Shell(EditorFP, vbNormalFocus)
          End If

The value of the variable EditorFP = C:\Program Files\Notepad++\notepad++.exe C:\Users\ 'User Name' \ 'Filename'.txt

When it tries to open the .txt file I first get the message:

"C\Users\ 'Name ~ (Just first name)'" doesn't exist. Create it?<

Followed with the next message:

"C\Users\ 'Name ~ (full name)'\OneDrive - 'CompanyName'\ 'Documents'\ 'lastname'\ 'Filename'.txt" cannot be opened: Folder "C\Users\ 'Name ~ (full name)'\OneDrive - 'CompanyName'\ 'Documents'\ 'lastname'" doesn't exist.<

Just to be clear. There is no space between \ and ' I just added it because without it, the post looked wierd in the preview (the \ disappeared).

本文标签: Problem Opening Textfile throught VBA Shell NotepadStack Overflow