I’m using VBA to code some macros in excel which work with my UiPath program but I’m having some issues. I’ve coded the following macro to copy a worksheet from one workbook and paste the values and formatting to a new worksheet in a different workbook.
When I run the code I get the following error: Exception from HRESULT 0x800A9C68, System.Runtime.InteropServices.COMException
Any help would be greatly appreciated!! Here’s my code:
Sub copySheetToMaster(sourcePath As String, destinationPath As String, masterShtName As String)
Dim srcBook, destBook As Workbook
'open workbooks
set srcBook = Workbooks.Open(sourcePath)
set destBook = Workbooks.Open(destinationPath)
srcBook.Worksheets("AllocationSheet").UsedRange.Copy Before:=destBook.Worksheets(1)
With destBook.Worksheets(1).Range("A1")
.PasteSpecial(xlPasteFormats)
.PasteSpecial(xlPasteValues)
End With
destBook.Worksheets(1).Name = masterShtName
I’m running an invoke VBA activity within an excel application scope in uipath.
Some of the cells in my workbook have formulas and if I try to switch it to xls (2013) it says I will have significant loss of functionality for any cells with a fomula so I’m not sure that I can change it to 2013.