Code:
Sub getdata()
cur_mon = Date - (Weekday(Date, 2) - 1)
cur_fri = Date + (5 - Weekday(Date, 2))
mondt = Year(cur_mon) & "-" & Day(cur_mon) & "-" & Month(cur_mon) & " 00:00:00"
fridt = Year(cur_fri) & "-" & Day(cur_fri) & "-" & Month(cur_fri) & " 00:00:00"
mydb = ............... (my sheet name)
mypath = ...... (path C:\ ...etc) & mydb
' Connet to database
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
With cn
.Provider = "MSDASQL"
.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};" & "DBQ=" & mypath & "; ReadOnly=False;"
.Open
End With
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM [Sheet1$]"
cn.Close
Set cn = Nothing
End Sub
I am trying to query a sheet , getting run time error 3709 on the line rs.Open.
any help ?