Showing results for 
Search instead for 
Did you mean: 

MS Excel VBO - Pasting Data From once Workbook to another Workbook

Level 2
Hi, I am new to BP. I'm trying to execute a scenario. Where i'm trying to copy the data from one workbook1 to another workbook2. 1. I'm able to copy the data from workbook1 2. Copied data is getting stored in a Data Collection 3. Able to open the workbook2 to paste the data 4. While writing the copied data to workbook2 i'm getting an error Error message: " Workbook Not Found : Workbook named: C:\Users\Administrator\Desktop\Book2.xlsx not found in instance: 0" Can someone please help me. Thank you.. Regards, Murthuja

Level 3
I have cracked it successfully by using Get collection and write collection VBO objects provided in BP. Thank You.

Can you describe the functions which you used like Create Workbook, Open Workbook, Write Collection etc?

Level 2
I am trying to Copy and Paste few cells 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))

Level 4
Hi,   Make sure you are doing it on the same handle. Do not create multiple handles.   When you create a handle use for all worksheets. Then copy paste will work.

Level 12

If you want a solution that'll also work across handles, copy and modify the action ""Copy and Paste Worksheet Range"" and just remove the destination variables, along with anything trying to paste. You can then make a paste action using PasteSpecial. Should look something like this.

Handle - Number
Workbook - Text
Paste Option - Number  (-4163 for values only, -4104 for all data)

Success - Flag
Message - Text

Dim wb, excel, range As Object
	wb = GetWorkbook(Handle, Workbook)
	excel = wb.Application
	range = excel.Selection
	range.PasteSpecial(Paste:=Paste_Option, Operation:=-4142, SkipBlanks:=False, Transpose:=False)
	Success = True 
Catch e As Exception
	Success = False
	Message = e.Message
	wb = Nothing
	range = Nothing
End Try