利用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

 

posted @ 2015-12-11 17:44  Lio5n  阅读(869)  评论(0编辑  收藏  举报