Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help on excel datatable operations
#1
Not Solved
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
Reply


Messages In This Thread
Need help on excel datatable operations - by SushantS - 11-19-2015, 04:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Copy Excel Worksheet to DataTable simon_schreiner 0 2,766 02-29-2012, 03:53 PM
Last Post: simon_schreiner
  Keyboard operations Rajesh 3 4,009 03-04-2008, 09:57 PM
Last Post: FredMan

Forum Jump:


Users browsing this thread: 1 Guest(s)