1
我連接到Excel表單,該表單充當數據庫。我需要選擇一些記錄與在那裏的條件,但我得到的錯誤:通過使用下面的代碼爲Excel數據源選擇語句
No value given for one or more required parameters
:
Dim conn As Object
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Set conn = CreateObject("ADODB.Connection")
XLName = "C:\Users\X\Desktop\rawdata.xlsx"
connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" &
XLName & "';Extended Properties='Excel 12.0;HDR=NO;IMEX=1';"
conn.Open connString
rs.Open ("SELECT * FROM [data$] where industry='Government'"), conn,
adOpenDynamic, adLockReadOnly
Sheet1.Range("A2").CopyFromRecordset rs
rs.Close
conn.Close
您確定「下面的代碼」是**完全**您在Visual Basic編輯器中有什麼?因爲沒有'_'行的延續,那代碼就無法編譯。 –