|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
各位老师好,我希望在Excel中导入外部Access的数据,用Excel2003不成功,但用Excel2007就成功了,于是我在2007中录制了一段宏,放入2003中,可是运行还是不成功。由于工作中必须使用2003,有什么办法啊?谢谢。
另外问一下,附件中有两张图片,是2003中跳出的,输入确定后就什么反应也没有了,不成功的原因是否和这两张图片有关?
Public Sub ab()
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=C:\Documents and Settings\xianc\桌面\1.mdb;Mode=ReadWrite;" _
, _
"Extended Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine T" _
, _
"ype=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New D" _
, _
"atabase Password="""";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compa" _
, _
"ct=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False;Jet OLEDB:Support Complex Data=False" _
), Destination:=Range("$A$1")).QueryTable
.CommandType = xlCmdTable
.CommandText = Array("表1")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.SourceDataFile = "C:\Documents and Settings\xianc\桌面\1.mdb"
.ListObject.DisplayName = "表__1"
.Refresh BackgroundQuery:=False
End With
End Sub
|
|