I get a Runtime error '1004' (application-defined or object-defined error) when I run the following macro in Excel. It stops on the "With Activesheet.QueryTables......" line.
Would anyone have any idea why this might be happening?
Sub WORKBASKET()
Dim sqlstring As String
sqlstring = "SELECT top 1 * FROM Teams"
connstring = _
"DSN=MS Access Database;" & _
"DBQ=C:\Reporting\Team.mdb;" & _
"DefaultDir=C:\Reporting;" & _
"DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"
MsgBox "1"
With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Range("A1"), Sql:=sqlstring)
.Refresh BackgroundQuery:=False
End With
End Sub
Would anyone have any idea why this might be happening?
Sub WORKBASKET()
Dim sqlstring As String
sqlstring = "SELECT top 1 * FROM Teams"
connstring = _
"DSN=MS Access Database;" & _
"DBQ=C:\Reporting\Team.mdb;" & _
"DefaultDir=C:\Reporting;" & _
"DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"
MsgBox "1"
With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Range("A1"), Sql:=sqlstring)
.Refresh BackgroundQuery:=False
End With
End Sub