F_EXPORT_TO_EXCEL

//Function Name : f_export_to_excel
//Argument Name : as_path, Arg Type : string, Pass By : Value
//Return Type : [None]

//Init docname
//GetFileOpenName or any other method
OLEObject Excel

If dw_1.SaveAs(as_path + ".xls", HTMLTable!, True) = -1 Then
    MessageBox("Warning", "Unable to export data. Error writing to file!", Exclamation!)
    Return
End If

//Convert HTML file to Excel native format
Excel = CREATE OLEObject

If Excel.ConnectToObject(as_path + ".xls") = 0 Then
    Excel.application.DisplayAlerts = FALSE
    Excel.application.workbooks(1).Parent.Windows(Excel.application.workbooks(1).Name).Visible = True
    Excel.application.workbooks(1).SaveAs(as_path + ".xls", 39)
    Excel.application.workbooks(1).Close()
End If

DESTROY Excel

0 comments:

Post a Comment