Pages

Tuesday, 18 October 2011

Export a data table at runtime.


' =============================================================
' function: ExportDataTable
' desc : Exports a data table
' params : strFile - full path to save the exported xls, note
' that any existing xls will be deleted
' returns : void
' =============================================================

Function ExportDataTable(strFile)

 

Dim objFS

 

' create a file system object
Set objFS = CreateObject("Scripting.FileSystemObject")

 

' check that the xls doesn't already exist
If objFS.FileExists(strFile) Then

 

    ' delete it if it exists
    ObjFS.DeleteFile strFile

End If

 

' export the data table
DataTable.Export strFile

 

' destroy the object
Set objFS = Nothing

 

End Function 'ExportDataTable

0 comments:

Post a Comment