pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875

Whenever i ruin this macro code that will extract data from other resource..it does not work but gives error
"Unrecognized Data format 'C:Book2.xls'.
I dont even know how this works but i hope someone in here will be able to solve this...
Thanks guys!
Sub proSQLQuery1()
Dim varConnection
Dim varSQL
Range("A1").CurrentRegion.ClearContents
varConnection = "ODBC; DSN=MS Access Database;DBQ=C:\Book2.xls; Driver={Driver do Microsoft Access (*.mdb)}"
varSQL = "SELECT tbDataSumproduct.Month, tbDataSumproduct.Product, tbDataSumproduct.City FROM tbDataSumproduct"
With ActiveSheet.QueryTables.Add(Connection:=varConnection, Destination:=ActiveSheet.Range("A1"))
.CommandText = varSQL
.Name = "Query-39008"
.Refresh BackgroundQuery:=False
End With
End Sub