利用VBA导出文件的例子
下面是利用VBA导出文件的例子,可以导出Excel内容等其他可以使用VBA的地方。
Sub export_file() Dim fs, ft As Object Dim txtname As String txtname = "export_file" Set fs = CreateObject("scripting.filesystemobject") Set ft = fs.createtextfile(ThisWorkbook.Path & "\" & txtname & ".sql") Dim Sql As String Sql = "This is a example!" ft.WriteLine (Sql) ft.Close Set ft = Nothing: Set fs = Nothing End Sub