记事本弹出窗口上的Vba用户窗体输出

记事本弹出窗口上的Vba用户窗体输出,vba,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) o

替换

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

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


另请参见和

您想做什么?将文本放入记事本而不先写入磁盘?
MsgBox ("Notes Generated Successfully in Documents Folder")
'Now this output should be on notepad instead of documents folder
Shell "notepad.exe /W """ & strPath & """", vbNormalFocus