|
- Sub 宏1()
- '
- ' 宏1 宏
- With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
- "OLEDB;Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Data Source=IDEA-PC\SQLEXPRESS;Use Procedure for Prepare=1;Auto Transl" _
- , _
- "ate=True;Packet Size=4096;Workstation ID=IDEA-PC;Use Encryption for Data=False;Tag with column collation when possible=False;Ini" _
- , "tial Catalog=alesdata"), Destination:=Range("$A$1")).QueryTable
- .CommandType = xlCmdTable
- .CommandText = Array("""alesdata"".""dbo"".""全年数据""")
- .RowNumbers = False
- .FillAdjacentFormulas = False
- .PreserveFormatting = True
- .RefreshOnFileOpen = False
- .BackgroundQuery = True
- .RefreshStyle = xlInsertDeleteCells
- .SavePassword = False
- .SaveData = True
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .PreserveColumnInfo = True
- .SourceConnectionFile = _
- "C:\Users\data\Documents\我的数据源\IDEA-PC_SQLEXPRESS alesdata 全年数据.odc"
- .ListObject.DisplayName = "表_IDEA_PC_SQLEXPRESS_alesdata_全年数据"
- .Refresh BackgroundQuery:=False
- End With
- Range("D5").Select
- End Sub
复制代码 大师,,这是我用宏录制的,,大师能否帮忙用Vba Ado 简化下,,谢谢大师。
|
|