Sub WriteFile(fname As String, txt As String) 'เขียน Text File
Dim fso As New FileSystemObject
Dim stream As TextStream
Set stream = fso.CreateTextFile(fname, True)
stream.Write (txt)
stream.Close
End Sub
Function SaveDialog() As String 'เปิด Dialog ถามชื่อ File
Dim ret As String
ret = Application.GetSaveAsFilename("Output.xml", _
"XML files (*.xml),*.xml", 1, "Save XML Output")
If ret <> "False" Then
SaveDialog = ret
End If
End Function
ถ้าจะใช้ FileSystemObject ต้อง reference Microsoft Scripting Runtime ด้วย โดยในหน้า VB ไปที่ Tool -> References...
ไม่มีความคิดเห็น:
แสดงความคิดเห็น