Can anyone please help me out
The error “VBA: Exception from HRESULT: 0x800A9C68” typically indicates that there is an issue with the VBA code that is being executed. This error can occur for a variety of reasons, such as a syntax error in the code, a missing reference, or an invalid operation.
To troubleshoot this error, you can try the following steps:
- Review the VBA code that is being executed and check for any syntax errors or invalid operations.
- Make sure that all of the required references are present and properly referenced in the code.
- Try restarting the UiPath Studio and re-running the project to see if the error persists.
- If the error continues to occur, you can try running the code in the VBA editor to see if the error is specific to UiPath or if it occurs in the VBA editor as well.
- If the error is specific to UiPath, you may need to contact UiPath support for further assistance.
These steps should help you troubleshoot the error and resolve the issue with your VBA code in UiPath.
Attribute VB_Name = “Module1Consolidate”
Sub Try()
Dim arrFiles As Variant
arrFiles = Array("2022_01_OMISFile_OMYA.xls", "2022_01_OMISFile_TRAD.xls", "2022_02_OMISFile_OMYA.xls", "2022_02_OMISFile_TRAD.xls")
Call Consolidate("C:\Temp\RPA0003_MonthlyEnvironmentalSales", "Automated Sales Report EVS 2020 - January 2022.xlsx", "Automated Sales Report EVS 2020 - February 2022.xlsx", arrFiles, DateAdd("m", -1, Date))
End Sub
Public Sub Consolidate(in_strTempPath As String, in_strOutputFile As String, in_strNewNameOutputFile As String, in_arrFiles As Variant, in_dateAnalysis as Date)
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim y As Integer
Dim i As Integer
Dim wbOutput As Workbook
Dim wbOMIS As Workbook
Dim rDataTable As Range
Dim rDataOutput As Range
Dim rDataOMIS As Range
Dim headers As Variant
Dim strQueryPath As String
If Right(in_strTempPath, 1) <> "\" Then in_strTempPath = in_strTempPath & "\"
strQueryPath = in_strTempPath & "Query\"
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'++++++++ Step 1 Clean Output Last Run +++++++++++++++++++++
'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'*************** Open and Clear Output Report of the current Year Data **********************
Set wbOutput = Workbooks.Open(Filename:=in_strTempPath & in_strOutputFile, ReadOnly:=False)
Set rDataOutput = wbOutput.Sheets("Data").UsedRange
Set rDataTable = wbOutput.Sheets("Data").Range(rDataOutput.Cells(7, 1), rDataOutput.Cells(rDataOutput.Rows.Count, rDataOutput.Columns.Count))
wbOutput.Sheets("Data").AutoFilterMode = False
rDataTable.AutoFilter field:=1, Criteria1:=Year(in_dateAnalysis)
If Application.WorksheetFunction.CountA(rDataTable.Columns(1).SpecialCells(xlCellTypeVisible)) > 1 Then
rDataTable.Range(rDataTable.Cells(2, 1), rDataTable.Cells(rDataTable.Rows.Count, 1)).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End If
wbOutput.Sheets("Data").AutoFilterMode = False
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'++++++++ Step 2 Add OMIS Data from Current Month +++++++++++++++++
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
For Each file In in_arrFiles
Set wbOMIS = Workbooks.Open(Filename:=strQueryPath & file, ReadOnly:=True, CorruptLoad:=True)
'*************** Capture Range of new Workbook (and delete extra columns) ********************
Set rDataOMIS = wbOMIS.Sheets(1).UsedRange
rLastTable = rDataOMIS.Range(“A” & 9).End(xlDown).Row
rDataOMIS.Range(“A” & rLastTable + 1 & “:A” & rDataOMIS.Rows.Count).EntireRow.Delete
'rDataOMIS.Columns(Application.Match(“Category”, rDataOMIS.Range(“8:8”), 0)).EntireColumn.Delete
'rDataOMIS.Columns(Application.Match(“Project ID”, rDataOMIS.Range(“8:8”), 0) + 1).EntireColumn.Delete
'rDataOMIS.Columns(Application.Match(“Project ID”, rDataOMIS.Range(“8:8”), 0)).EntireColumn.Delete
'*************** Paste Format Downwards ******************************
rDataOMIS.Range(rDataOMIS.Cells(9, 1), rDataOMIS.Cells(rDataOMIS.Rows.Count, 1)).EntireRow.Copy
rDataTable.Cells(rDataTable.Rows.Count + 1, 1).PasteSpecial xlValues
rDataTable.Cells(rDataTable.Rows.Count + 1, 1).PasteSpecial xlPasteFormats
Application.CutCopyMode = False
'*************** Recalculate the Full Range **************************
Set rDataOutput = wbOutput.Sheets(“Data”).UsedRange
Set rDataTable = wbOutput.Sheets(“Data”).Range(rDataOutput.Cells(7, 1), rDataOutput.Cells(rDataOutput.Rows.Count, rDataOutput.Columns.Count))
wbOMIS.Close savechanges:=False
Next file
'++++++++++++++++++++++++++++++++++++++++++++++++++++
'++++++++ Step 3 Update Pivot Table +++++++++++++++++
'++++++++++++++++++++++++++++++++++++++++++++++++++++
wbOutput.Sheets(“Pivot”).PivotTables(1).ChangePivotCache wbOutput.PivotCaches.Create(xlDatabase, rDataTable)
wbOutput.Sheets(“Pivot”).PivotTables(1).PivotCache.Refresh
wbOutput.Sheets(“Pivot”).PivotTables(1).RefreshTable
Dim a As Worksheet
Dim b As PivotTable
wbOutput.SaveAs Filename:=in_strTempPath & in_strNewNameOutputFile
wbOutput.Close savechanges:=True, Filename:=in_strTempPath & in_strOutputFile
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
tHIS IS THE CODE CAN YOU CHECK IF ANYTHING WRONG INTO IT