VBSCript Issues
-
I am having 5 VB Scripts which copies the data from One Excel to another excel..All the scripts just need to mention the Page name in it but only one VB script which gives the error
C:\chat.vbs(5, 1) Microsoft VBScript runtime error: Subscript out of range
What may be the issue ?
Verifying this link for .vbs
https://quicktestprofessional.wordpress.com/2008/06/09/copy-an-excel-sheet-to-another-excel/
-
That particular error means that your script can't find the sheet you are looking for. Check and see if you need to subtract one from the number you are using. VBScript starts counting with 0 (zero) and not 1.
-
@dafyre Actually I am having 6 Sheet in One Excel File where Sheet 1 not disturbed,
Sheet 2,3,4,5 where copied the files from the source path provided.This is the 6th Sheet which through error -
@lakshmana said in VBSCript Issues:
@dafyre Actually I am having 6 Sheet in One Excel File where Sheet 1 not disturbed,
Sheet 2,3,4,5 where copied the files from the source path provided.This is the 6th Sheet which through errorAre you using a for loop to go through the Sheets?
-
@dafyre No.Verify this
Set objExcel = CreateObject(“Excel.Application”)
objExcel.Visible = True
Set objWorkbook1= objExcel.Workbooks.Open(“C:\Documents and Settings\mohan.kakarla\Desktop\1.xls”)
Set objWorkbook2= objExcel.Workbooks.Open(“C:\Documents and Settings\mohan.kakarla\Desktop\2.xls”)
objWorkbook1.Worksheets(“Sheet1”).UsedRange.Copy
objWorkbook2.Worksheets(“Sheet1”).Range(“A1”).PasteSpecial Paste =xlValues
objWorkbook1.save
objWorkbook2.save
objWorkbook1.close
objWorkbook2.close
set objExcel=nothing -
@lakshmana said in VBSCript Issues:
objWorkbook2.Worksheets(“Sheet1”).Range(“A1”).PasteSpecial Paste =xlValues
There should be a Colon after the Paste and before the = sign....
Paste:=xlValues ?