vishalmchavan
New Member
Hello,
I am using following vb script to copy data from one Excel Workbook to different Excel's workbook.
I am using two csv files as my source and target.
I want to copy all cells from lets say XPI_Defects.csv and append it to that of CRM_Defects.csv
I am able to copy it for the first run of vb script.
However I am facing two problems.
1> when I run it second time vb script throws warning of Excel has detected that XPI_Defects.csv is SYLK file but can not load it. Either the file has errors or it is not a SYLK file.
2> Also it asks user whether two save file. I want it to be saved automatically without prompting exception.
3> I want to copy all data except first row from XPI_Defects.csv file to CRM_Defects.csv file. How to avoid copying of first row since it is a header of table.
4> How to pass cell or range using a variable?
Could you please help ?
Function fCopy
Set myexl = createObject("Excel.Application")
myexl.Visible = True
'Open a workbook1
Set Workbook1= myexl.Workbooks.Open("C:UsersvichavanDesktopQTP91P1602Excel ScriptsXPI_Defects.csv")
'Open a workbook2
Set Workbook2= myexl.Workbooks.Open("C:UsersvichavanDesktopQTP91P1602Excel ScriptsCM_defects.csv")
Set readsheet = Workbook2.Worksheets("CM_defects")
lastcell = readsheet.UsedRange.Rows.Count
lastcell = lastcell + 1
Workbook1.Worksheets("XPI_Defects").UsedRange.Copy
'Range("A1").End(xldown).Select
Workbook2.Worksheets("CM_Defects").Range("A902").PasteSpecial Paste = xlValues
'Save the workbooks
Workbook1.save
Workbook2.save
'close the workbooks
Workbook1.close
Workbook2.close
myexl.Application.Quit
set myexl=nothing
End Function
Thanks in Advance,
Vishal
I am using following vb script to copy data from one Excel Workbook to different Excel's workbook.
I am using two csv files as my source and target.
I want to copy all cells from lets say XPI_Defects.csv and append it to that of CRM_Defects.csv
I am able to copy it for the first run of vb script.
However I am facing two problems.
1> when I run it second time vb script throws warning of Excel has detected that XPI_Defects.csv is SYLK file but can not load it. Either the file has errors or it is not a SYLK file.
2> Also it asks user whether two save file. I want it to be saved automatically without prompting exception.
3> I want to copy all data except first row from XPI_Defects.csv file to CRM_Defects.csv file. How to avoid copying of first row since it is a header of table.
4> How to pass cell or range using a variable?
Could you please help ?
Function fCopy
Set myexl = createObject("Excel.Application")
myexl.Visible = True
'Open a workbook1
Set Workbook1= myexl.Workbooks.Open("C:UsersvichavanDesktopQTP91P1602Excel ScriptsXPI_Defects.csv")
'Open a workbook2
Set Workbook2= myexl.Workbooks.Open("C:UsersvichavanDesktopQTP91P1602Excel ScriptsCM_defects.csv")
Set readsheet = Workbook2.Worksheets("CM_defects")
lastcell = readsheet.UsedRange.Rows.Count
lastcell = lastcell + 1
Workbook1.Worksheets("XPI_Defects").UsedRange.Copy
'Range("A1").End(xldown).Select
Workbook2.Worksheets("CM_Defects").Range("A902").PasteSpecial Paste = xlValues
'Save the workbooks
Workbook1.save
Workbook2.save
'close the workbooks
Workbook1.close
Workbook2.close
myexl.Application.Quit
set myexl=nothing
End Function
Thanks in Advance,
Vishal