Pages

Tuesday, 18 October 2011

Export a data sheet at runtime.



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

Function ExportDataSheet(strFile, strSheet)

 

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.ExportSheet strFile, strSheet

 

' destroy the object
Set objFS = Nothing

 

End Function 'ExportDataSheet



0 comments:

Post a Comment