cancel
Showing results for 
Search instead for 
Did you mean: 

MS Excel VBO Copy And Paste

Anonymous
Not applicable
MS Excel VBO Copy And Paste action giving 'Failed to copy worksheet: Invalid Index' error. Please guide. Thanks. Soumya
11 REPLIES 11

RobinToll
Staff
Staff
Invalid Index means it thinks you're telling it to either copy or paste to a row/column that doesn't exist. Try checking your indexes against the actual data and make sure you're referencing rows and columns which actually exist in the file. Thank you, -Robin Toll

suchit_tripathy
Level 2
I am trying to Copy and Paste two rows from one excel file to another excel file by using EXCEL VBO with the action ""Copy and Paste Worksheet Range"" but getting the error : Failed to copy worksheet: Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))

RadoslavHiko
Level 4
I think you also need to open both Excel files under the same Excel instance.

I was facing the issue and able to solve it by following the below steps.

1. Create Instance
2. Open SourceWorkbook -- Output you write to some data item called WorkBookName1
3. Open DestinationWorkbook -- Output you write to some data item called WorkBookName 2
4. Show
5. Copy and Paste worksheet range Action (Parameters are the key here)
          handle
          SourceWorkBook name  = WorkBookName1 (This is the output variable of step 2)   ---  Do not pass Full file path name here
          DestinationWorkBook name  =  WorkBookName2 (This is the output variable of step 3 )  ---  Do not pass Full file path name here
         Source Sheet, Destination Sheet and Ranges are as per your requirements.
6. Save and Close Instance

Hope this helps.. 

Sharath


------------------------------
Sharath Kumar Pennada
Consultant
Deloitte Consulting India Private Limited
Asia/Kolkata
------------------------------

Solid solution. Just want to add that I have some mixed experience with the "Show" action in the MS Excel VBO, the workflow should be functional without calling that action. So I don't think the action should be used post development

/Joakim

------------------------------
Joakim Eklund
Senior RPA Developer
Swedbank AB
Europe/Stockholm
------------------------------

I completely agree with you Joakim.
I'm not a big fan of using Show action after development.
But Blue Prism is suggesting to use 'show' action for this 'copy and paste worksheet as range' action.
This should do no harm in this case.


------------------------------
Sharath Kumar Pennada
Consultant
Deloitte Consulting India Private Limited
Asia/Kolkata
------------------------------

How Do we Write the Source Range and Destination range? Can anyone give me example

11787.png

------------------------------
Kumaresan Ganesan
IT Support Specialist
Association of International Certified Professional Accountants
Asia/Kuala_Lumpur
------------------------------

True, Show really helps in copy paste action.

------------------------------
Ravi Kumar
Sr Automation Designer
Ericsson
Asia/Kolkata
------------------------------

Hi @KumaresanGanesa,

Try giving the source range as "A17:BC:3000" and destination range as "A1" only and see if you are getting the desired outcome.

------------------------------
----------------------------------

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
Wonderbotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------
------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please provide a big thumbs up so that the others members in the community having similar problem statement can track the answer easily in future.

Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Technical Business Analyst,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com

----------------------------------