Macro won't run after upgrading from Excel 2010

UndwaterExcelWeaver

New Member
Joined
Mar 2, 2019
Messages
38
Office Version
  1. 365
Platform
  1. Windows
Hello. The module below is part of a very large VBA code that draws in data from an exported file. When we upgraded to Excel 2013/365 this no longer works and gets hung up at the "rs.open" line. Can you tell me what has changed and what I need to change to get this to move forward again past this point? I do not know VBA very well at all. These were written long before my time with my company and I'm just trying to make them functional again. Thanks

Private Sub GetResultSet( _
ByRef rs As ADODB.Recordset, _
ByVal cn As ADODB.Connection, _
ByVal strSQL As String _
)

rs.CursorLocation = adUseClient
rs.Open strSQL, cn, adOpenForwardOnly, adLockReadOnly, adCmdText

On Error GoTo 0
If rs Is Nothing Then
MsgBox "Can't open the file!", vbExclamation, ThisWorkbook.Name
Exit Sub
End If

End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I am guessing that you are missing a library in VBA.

If you go into the VB Editor, go to the Tools menu and select "References".
Then see if it says you are missing any VBA libraries. If so, find it in the list (or the nearest version), and select it.

The easiest way to typically find which library is needed is to check it on a computer where it still works. If you follow the same steps as above, you can see which libraries it needs, and then select the same ones on the new system (usually similiar names, but different version numbers).

EDIT:
Based on this article here: Using ADO with Microsoft Visual Basic - ActiveX Data Objects (ADO)
it looks like the library you need to select is named something like: Microsoft ActiveX Data Objects x.x Library
Just pick the highest verion number it shows.
 
Upvote 0
I am guessing that you are missing a library in VBA.

If you go into the VB Editor, go to the Tools menu and select "References".
Then see if it says you are missing any VBA libraries. If so, find it in the list (or the nearest version), and select it.

The easiest way to typically find which library is needed is to check it on a computer where it still works. If you follow the same steps as above, you can see which libraries it needs, and then select the same ones on the new system (usually similiar names, but different version numbers).

EDIT:
Based on this article here: Using ADO with Microsoft Visual Basic - ActiveX Data Objects (ADO)
it looks like the library you need to select is named something like: Microsoft ActiveX Data Objects x.x Library
Just pick the highest verion number it shows.
"References" is greyed out in the both the working and non-working versions of excel.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top