I have an Excel file that is using an ADODB connection to read and write to a closed workbook. It runs on my laptop, using a locally stored file from which to read from and write to. (Office Professional Plus 2016, Win32).
When I copy the file to a network, Excel crashes when attempting to open the connection.
The network has Office Professional Plus 2010 32-bit version, and its on a Remote Desktop.
Sub GetData()
'To get data from closed Store Master File
Dim strSQL As String ' used to execute a request
Dim strSfile As String ' the name of the source file
Dim strServer As String ' the drive where the source file is located
Dim strpath As String ' the path on the drive where the file is located
Dim sFile As String ' concat of server/path/file
Dim constr As String ' the connection string
Dim cnn As New ADODB.Connection ' the connection
'Set connection to the Store Master file
strServer = "P:\"
strpath = Sheets("Control").Range("A2").Value
strSfile = Sheets("Control").Range("A5").Value
sFile = strServer & strpath & strSfile
constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" & sFile & "';Extended Properties=""Excel 12.0;HDR=YES;"";"
'Open connection
cnn.Open constr ' the problem line
'.... other lines of code
cnn.Close
End Sub
On attempting to debug the problem, cnn.Open constr is where Excel crashes. So no VBA error data is available.
I returned the result of the sfile variable to the immediate window and copied to open the Excel file. So I know its not a problem with the file name and path.
Appears the only error information I have is:
Problem Event name: APPCRASH
Application Name: EXCEL.EXE
Application Version: 14.0.7256.5000
Fault Module: mso.dll
Fault Module Version: 14.0.7257.5000
Exception Code: c00000005
Exception Offset: 00bb441f
OS Version: 6.1.7601.2.1.0.16.7
Locale ID: 3081
Additional information:
LCID: 1033
skulcid: 1033