尝试使用ADODB.Connection连接到2010 excel文件时,我的脚本失败。
我已经阅读了有关32位v 64位的所有内容,但仍无法使其正常工作。
是否有一种简单的方法可以连接到excel文件并使用vb脚本获取一些数据......?感谢
'## Create, Open, and Close Excel Object
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Open("\\WWAUDB01\MKTGDA_Raw\US\AU Subscription Payment Report*")
Dim varh
varh = "Hello"
copyData objExcel
sub copyData(book)
set objDestXL = CreateObject("Excel.Application")
objDestXL.Visible = True
set objDestWrkBk = objDestXL.Workbooks.Add
set objDestWrkSht = objDestWrkBk.Sheets.Add(, objDestWrkBk.Sheets(objDestWrkBk.Sheets.Count))
Dim myConString
Dim myConn
Dim myRS
'Define Variables
'Define the connection string
myConString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\\WWAUDB01\MKTGDA_Raw\US\AU Subscription Payment Report*;"
'Gain access to ADODB Connection and Recordset objects
Set myConn = CreateObject("ADODB.Connection")
Set myRS = CreateObject("ADODB.Recordset")
'Establish the Connection
myConn.Open myConString
'Open a recordset in the connection. A sheet or range are valid
myRS.Open "SELECT * FROM [Sheet1$]", myConn
end sub
objExcel.Quit