I have an applications that works fine using Windows 10 & both Excel 2013 & 2019 & I am using visual studio 2019. I have just upgraded to Windows 11 and Office 2021 Pro & the program will no longer open the same Excel file & gives the following error message:-
"System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'"
No other changes have been made to the working program.
The code concerned is:-
Public XL_Connection_string As String
Public XL_Connection As New OleDb.OleDbConnection
Dim EXCEL_Connection_String_NoHeader As String = "Provider=Microsoft.ACE.OLEDB.##.0; Data Source=""XXX""; Extended Properties=""Excel ##.0 Xml;HDR=NO"""
XL_Connection_string = Replace(EXCEL_Connection_String_NoHeader, "XXX", strLoadVehiclesFileName)
XL_Connection_string = Replace(XL_Connection_string, "##", OfficeVersion)
XL_Connection.ConnectionString = XL_Connection_string
XL_Connection.Open()
The program fails on the XL_Connection.Open() instruction.
strLoadVehiclesFileName is set to the excel filename to be opened. OfficeVersion is set to 15 for Office 2013 & 16 for Office 2021.
Have I missed something that I need to change for Office 2021? Any help to solve this will be much appreciated.