记事本弹出窗口中的Vba Userform输出

时间:2015-08-04 05:29:23

标签: vba

Private Sub PrNotes_Click()
Dim fso As Object
Dim strPath As String

Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object

strPath = TextBox1.Value & " Order Notes.txt"
Set oFile = fso.CreateTextFile(strPath)

            oFile.writeline "Name : " & TextBox1.Value
            oFile.writeline "Contact : " & TextBox2.Value
            oFile.writeline "Email : " & TextBox3.Value
oFile.Close
Set fso = Nothing
Set oFile = Nothing
MsgBox ("Notes Generated Successfully in Documents Folder")
'Now this output should be on notepad instead of documents folder

End Sub

1 个答案:

答案 0 :(得分:0)

替换

MsgBox ("Notes Generated Successfully in Documents Folder")
'Now this output should be on notepad instead of documents folder

Shell "notepad.exe /W """ & strPath & """", vbNormalFocus

警告:您必须知道strPath处文件的编码,才能在/A(即ASCII)和/W之间进行选择,即Unicode。

另请参阅Notepad.exe command line options Shell at Office Support