Need help on excel datatable operations - Printable Version +- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums) +-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP) +--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming) +--- Thread: Need help on excel datatable operations (/Thread-Need-help-on-excel-datatable-operations) |
Need help on excel datatable operations - SushantS - 11-19-2015 Hi I am new to QTP. Need help on excel datatable operations. I have 4 excel files in a folder. I need to convert all excel files to CSV. I have written below code, but somehow it wont work. getting error message as "Open method of Workbooks class failed". Please find below my code: Option Explicit Dim TotRow,i,ExcelObj,Sourcefile,TargetFile TotRow = DataTable.LocalSheet.GetRowCount For i = 1 To TotRow Set ExcelObj = CreateObject("Excel.Application") ExcelObj.DisplayAlerts = False ExcelObj.Visible = False '' Sourcefile = Datatable("SourceFile",dtlocalsheet) '' '' TargetFile = Datatable("TargetFile",dtlocalsheet) ExcelObj.Workbooks.Open Datatable("SourceFile",dtlocalsheet) ExcelObj.SaveAs Datatable("TargetFile",dtlocalsheet) ExcelObj.Application.Quit Next Datatable Details: Sourcefile [i]TargetFile[/i] C:\QTP\ExpectedReports\a.xlsx C:\QTP\ExpectedReports\a.csv C:\QTP\ExpectedReports\b.xlsx C:\QTP\ExpectedReports\b.csv C:\QTP\ExpectedReports\c.xlsx C:\QTP\ExpectedReports\c.csv C:\QTP\ExpectedReports\d.xlsx C:\QTP\ExpectedReports\d.csv Please Note: If I provide full path of sourcefile and targetfile then code works. but I don't want to enter those each time as there are 1000 of files in a folder which I need to concert to CSV. Thanks, Sushant RE: Need help on excel datatable operations - vinod123 - 12-18-2015 Instead of using QTP script use vbscript Code: '------------------- SET SEMI-COLON DELIMITER VIA WIN REGISTERS --------------- |