We have an Excel Template that utilizes VBA. This Template has worked fine until we upgraded to Office 2013. It is now throwing aRuntime error 3704 - Operation is not allowed when the object is closed, when the template is opened.
The code it is failing on is as follows. When debugged it points to the underlinedconn.Close. Thanks in advance for any assistance.
Steven
Private Sub Workbook_Open()Dim connStr As String
Dim rs As ADODB.Recordset
Dim conn As ADODB.Connection
ActiveWorkbook.Worksheets("Constants").Activate
connStr = ActiveWorkbook.Worksheets("Constants").Range("ConnectionString").Value
row = ActiveWorkbook.Worksheets("Constants").Range("FirstDropDownRow").Value - 1
'clear out old dropdown data
' ActiveWorkbook.Worksheets("Constants").Range(Cells(row + 1, 1), Cells(1000, 3)).Select
' Selection.ClearContents
On Error GoTo Err_Handler
Set conn = New ADODB.Connection
conn.Open connStr
'Get the summary level drop down choices
row = GetDropDownChoices(conn, "SummaryLevels", row + 1)
'Get the scaling and allocation ratio drop down choices
row = GetDropDownChoices(conn, "Ratios", row + 1)
'Get the operator drop down choices
row = GetDropDownChoices(conn, "Operators", row + 1)
'save the row at this point so that we can use it later when the
'summary and criteria columns are redone
ActiveWorkbook.Worksheets("Constants").Range("FirstDynamicDropDownRow").Value = row
conn.Close
'Get the summary columns down choices and
'Get the criteria columns down choices
Call RefreshDropDowns
ActiveWorkbook.Worksheets("Parameters").Activate
ActiveWorkbook.Worksheets("Parameters").Range("M5").Select
Exit Sub
Err_Handler:
conn.Close
End Sub