Problem
Our office PC's all run Office 365 ProPlus and are progressively getting updated to version 1908 (Build 11929.20562). As PC's get updated, many of our VBA macros are failing with various Object errors. We are getting the errors in two products so far, Outlook and WRQ Reflections (terminal emulator).
Examples
Sub master_dailyWhispirSMS_P2(myExcel As Excel.Application, myWorkbook As Excel.Workbook, worksheetName As String, testingMode As Boolean)
While Trim(myWorkbook.Worksheets(worksheetName).Cells(rowNum, 1).Value) <> ""
The above code resulted in a Run-time error '91' Object variable or With block variable not set
Dim myExcel As Excel.Application
Dim myWorkbook As Excel.Workbook
Set myExcel = GetObject(, "Excel.Application")
myExcel.Workbooks.Open (folderPath & "\" & fileName)
Set myWorkbook = myExcel.Workbooks(fileName)
myWorkbook.Activate
The above code resulted in the error Compile error: Method or data member not found. The compile error was on MyWorkbook.Activate.
Findings
The common theme so far is that we are using early binding and using objects from the Microsoft Excel Object Library.
I tried changing to using late binding and it got me past one issue, but there are way too many routines that might need updating.
From within the VBA Editor, on the Tools menu, under References, the Microsoft Excel 16.0 Object Library is showing as selected. I tried removing the reference and then adding it back again and this seems to have solved the issues. This worked on my colleagues PC as well.
Ideas/Solution Sought
This code used to work fine prior to the Office update. Other than getting each individual user to perform the remove/add, I'm trying to understand what has gone wrong and if there are any other alternatives to fixing this please.
Please note I am still very 'green' with my understanding of early and late binding, but I think somehow the references to the object libraries are either corrupt or just not pointing to the correct DLL file after the update. This would explain why the various methods are not working.