|
- Dim rs As New ADODB.Recordset
- Dim sSQL As String
- Dim xlApp As New Excel.Application
- Dim xlBook As Excel.Workbook
- Dim xlSheet As Excel.Worksheet
- Dim xlQuery As Excel.QueryTable
-
- sSQL = "SELECT 图,FTC,款号,合同,IntentNo,款式,面料,颜色,尺码,数量,交期,印绣花,搭配,辅料,主标 FROM 订单"
- rs.CursorLocation = adUseClient
- rs.Open sSQL, CurrentProject.Connection, adOpenKeyset, adLockReadOnly
- Set xlBook = xlApp.Workbooks().Open(CurrentProject.Path & "\导出模板.xltx", , True)
- xlApp.DisplayAlerts = False
- xlBook.SaveAs CurrentProject.Path & "\导出模板.xlsx" '另存为不同的文件名,
- Set xlSheet = xlBook.Worksheets("订单")
- xlSheet.Activate
- Set xlQuery = xlSheet.QueryTables.Add(rs, xlSheet.Range("A2"))
- With xlQuery
- .FieldNames = False
- .AdjustColumnWidth = False
- .Refresh
- .Delete
- End With
- rs.Close
- Set rs = Nothing
- xlBook.Save
- xlApp.DisplayAlerts = True
- xlApp.WindowState = xlMinimized
- xlApp.WindowState = xlMaximized
- xlApp.Application.Visible = True
-
- Set xlQuery = Nothing
- Set xlSheet = Nothing
- Set xlBook = Nothing
- Set xlApp = Nothing
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|