ML
    • Register
    • Login
    • Search
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups

    VBSCript Issues

    IT Discussion
    2
    6
    546
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Lakshmana
      Lakshmana last edited by Lakshmana

      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/

      1 Reply Last reply Reply Quote 0
      • dafyre
        dafyre last edited by

        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.

        Lakshmana 1 Reply Last reply Reply Quote 0
        • Lakshmana
          Lakshmana @dafyre last edited by

          @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

          dafyre 1 Reply Last reply Reply Quote 0
          • dafyre
            dafyre @Lakshmana last edited by

            @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 error

            Are you using a for loop to go through the Sheets?

            Lakshmana 1 Reply Last reply Reply Quote 0
            • Lakshmana
              Lakshmana @dafyre last edited by

              @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

              dafyre 1 Reply Last reply Reply Quote 0
              • dafyre
                dafyre @Lakshmana last edited by

                @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 ?

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post