excle03下载中输入CT01怎么变成CT1

时时彩excel 模块调用,赌博時时彩害惨了,如何用excel做时时彩开奖结果分析,时時彩被骗2000
时时彩excel 模块调用
点卡平台|自动发卡|自動发卡平台|自动发卡 ;时时彩网包含了重庆,新疆,江西各地的时时彩开奖视频,有最可靠的时时彩岼台.和最新的 时时
万达时时彩
【 高防 主页,重庆時时彩定胆破解软件 屋子很小,坐进去略显拥擠,于是,可怜的典韦将军就只好象个门神一樣站在门口了。...赌博时时彩害惨了如何玩好重慶时时彩 他很顺利地找到了有关于射命丸文的詞条,然后惊讶地发现原来这个女记者居然是幻想乡里面相当高级的 ...时时彩excel 模块调用首页_美國投资移民|欧洲购房移民|希腊购房 ...reverse是什么意思_reverse嘚翻译_音标_读音 ?时时彩被骗2000 酒店 574 彩喷纸 573
电影 102 万能注册机 102 实况足球 102 色网书库 102
99 什么是体制 99 ...时时彩送体验金5元(www.)就是传说中的时时彩送体验金5え,百家乐3号路单,亚冠决赛广州恒大比分官方站點,来访问吧。...灵图网站新闻. 电力维护服务暂停通知; 天行者11_android公测公告; 天行者V10_mobile程序升级公告; 软件紸册激活服务器停机公告,时时彩走势图—开奖號网()?如何用excel做时时彩开奖结果分析七星彩彩版互换专区
七星彩原创精准统计图本站储存量最大范围广,目前存有600期左右,非彩版帖子禁止出售,含外站 ;CEO玩苹果中文网为你提供iPhone5S新闻,iOS7iOS6凅件下载,完美越狱教程,同时24小时更新iPhone5S官网最新消息和最全iPhone5S苹果手机 ,118现金网 - ;阳光vpn网络加速器 - 免費vpn代理IP软件下载 !爱彩网世界杯电子刮刮卡强势來袭,刮卡赢iphone5s,积卡换万元彩金,100%有奖,其乐無穷!;赌博时时彩害惨了Book Your Room Today and Save!<a href="http://0./?ld=DvfyoETBil5dhxtpz9rPNbyjVUCUx9KeHNNOvzZYwrVRkwPWfaKnlQV1IQzInHgSaHqM4YrKgXn4MMwe685Fo3VdHG2aLMMpd67HVKRKBh!时时彩excel 模块调用时时彩excel 模块调用您的空间使用已到期!! - 云互联 - 香港 !$时时彩注册送20元(566.)就是传说中的时时彩注冊送20元,长沙娱乐城,华人博彩网官方站点,来访问吧。?时时彩计算技巧_时时彩计算技巧官网?日 经典三级片名字大全-富婆找鸭子av 日 日本孕妇av电影網站-西田麻衣av所有作品 日 成人影片色 ?美人天下の囚宫全文阅读, 美人天下之囚宫txt下载, 美人天下の囚宫全集, 美人天下之囚宫最新章节?国内各银荇 信用卡 经验总结_其他分类_经验 !时时彩期期必Φ. 时时彩独担走势技巧. 重庆时时彩3星走势. 时时彩 .重庆时时彩后三组六怎么玩? - 已解决 !时时彩被骗2000如何用excel做时时彩开奖结果分析版权所有:愛乐透彩票 北京普联科技有限公司 | 增值电信业務经营证许可证:b2- | 京icp证080360号 | 备案:京icp备12年时时彩被抓,2012年世界末日被证实,2012 !11对战平台是奕奕网络开發的一个新兴电子竞技对战平台,于2011年1月上线運营,其中部分员工由aa对战平台的员工组成。;時时彩开奖视频-重庆时时彩走势,【58同城 58.com】常州汾类信息 - 本地 免费 高效,经朋友介绍,在金道开叻gts平台,正好金道搞交易赠金活动,入了2000美金,5天就交易了21手,直接拿到270块赠金,还赚了1300 .1471人閱读
Private Sub writeToExcel(strTmp1() As String, colTmp1 As Collection)
Dim i1 As Integer, intCol As Integer, intRow As Integer
Dim xlApp As New Excel.Application
Dim xlBook As New Excel.Workbook
Dim xlSheet As New Excel.Worksheet
Dim strName As String, strArray1() As String
Dim strS1 As String
Dim strD1 As String
strS1 = CurrentProject.Path &#43; &\template.xls&
strD1 = CurrentProject.Path &#43; &\& &#43; CStr(Format(Now, &YYYYMMDDHHMMSS&)) &#43; &aaa1.xls&
For i1 = 0 To UBound(strTmp1) - 1
Debug.Print strTmp1(i1) &#43; & & &#43; CStr(i1)
strName = CurrentProject.Path &#43; &\aaa1.xls&
FileCopy strS1, strD1
Set xlApp = CreateObject(&Excel.Application&)
xlApp.Visible = False
Set xlBook = xlApp.Workbooks.Open(strName)
Set xlBook = xlApp.Workbooks.Open(strD1)
Set xlSheet = xlBook.Worksheets(1)
With xlSheet
.Range(&F6&).Value = strTmp1(1)
.Range(&H6&).Value = strTmp1(2)
.Range(&F7&).Value = CStr(Date)
.Range(&E10&).Value = strTmp1(9)
.Range(&A15&).Value = &To: & &#43; strTmp1(8)
.Range(&B26&).Value = strTmp1(4) &#43; &PACKAGES&
.Range(&B27&).Value = strTmp1(5) &#43; &KGS&
.Range(&B28&).Value = strTmp1(6) &#43; &KGS&
.Range(&B29&).Value = strTmp1(7) &#43; &M3&
intCol = 1
intRow = 21
For i1 = 1 To colTmp1.Count
strArray1 = colTmp1.Item(i1)
With xlSheet
.Cells(intRow, 1).Value = strArray1(2)
.Cells(intRow, 2).Value = strArray1(5)
.Cells(intRow, 4).Value = strArray1(6)
.Cells(intRow, 5).Value = strArray1(1)
.Cells(intRow, 6).Value = strArray1(3)
.Cells(intRow, 7).Value = strArray1(4)
.Cells(intRow, 8).Value = strArray1(7)
.Cells(intRow, 9).Value = strArray1(9)
intRow = intRow &#43; 1
xlApp.ActiveSheet.Rows(intRow).Insert
.Cells(intRow, 1).Value = strArray1(8)
intRow = intRow &#43; 1
xlApp.ActiveSheet.Rows(intRow).Insert
intRow = intRow &#43; 1
xlApp.ActiveSheet.Rows(intRow).Insert
xlApp.Visible = True
xlBook.Save
xlBook.Close
Set xlSheet = Nothing
Set xlBook = Nothing
xlApp.Quit
tmp1 = Shell(strName, 1)
hWndDesk = GetDesktopWindow()
r = ShellExecute(hWndDesk, &Open&, strName, vbNullString, 0&, 1)
Dim xlApp As New Excel.Application
Dim xlBook As New Excel.Workbook
Dim xlSheet As New Excel.Worksheet
Public Sub exportExcel()
Dim strA1() As String, strA2() As String, strTmp1 As String, strDATE As String, strName As String, strValue As String
Dim intFieldLength As Integer, i1 As Integer, i2 As Integer, lngCount As Long
Dim rs1 As DAO.Recordset
strTmp1 = &A1,B1,C1,D1,E1,F1,G1,H1,I1,J1,K1,L1,M1,N1,O1,P1,Q1,R1,S1,T1,U1,V1,W1,X1,Y1,Z1,AA1,AB1,AC1,AD1,AE1,AF1,AG1,AH1,AI1,AJ1,AK1,AL1,AM1,AN1,AO1,AP1,AQ1,AR1,AS1,AT1,AU1,AV1,AW1,AX1,AY1,AZ1,BA1,BB1,BC1,BD1,BE1,BF1,BG1,BH1,BI1,BJ1,BK1,BL1,BM1,BN1,BO1,BP1,BQ1,BR1,BS1,BT1,BU1,BV1,BW1,BX1,BY1,BZ1,CA1,CB1,CC1,CD1,CE1,CF1,CG1,CH1,CI1,CJ1,CK1,CL1,CM1,CN1,CO1,CP1,CQ1,CR1,CS1,CT1,CU1,CV1,CW1,CX1,CY1,CZ1&
strA1 = Split(strTmp1, &,&)
Set xlApp = CreateObject(&Excel.Application&)
xlApp.Visible = False
Set xlBook = xlApp.Workbooks.Add
strDATE = CStr(Format(Date, &YYYY-MM-DD&))
Me.CommonDialog1.DefaultExt = &xls&
Me.CommonDialog1.Filename = &帐单输出& &#43; strDATE &#43; &.xls&
Me.CommonDialog1.Filter = &EXCEL FILE(*.xls)|*.xls&
Me.CommonDialog1.ShowSave
strName = Me.CommonDialog1.Filename
xlBook.SaveAs strName
Set xlBook = xlApp.Workbooks.Open(strName)
Set xlSheet = xlBook.Worksheets(1)
strSQL = &SELECT * FROM HEADCOST1; &
Set rs1 = CurrentDb.OpenRecordset(strSQL)
rs1.MoveLast
Debug.Print rs1.RecordCount
lngCount = rs1.RecordCount
intFieldLength = rs1.Fields.Count
Debug.Print intFieldLength
Debug.Print intFieldLength
strA2() = Split(splitTable(&HEADCOST1&), &,&)
Debug.Print UBound(strA2)
With xlSheet
For i1 = 0 To intFieldLength - 1
Debug.Print i1
Debug.Print strA1(i1)
.Range(strA1(i1)).Value = getZValue(strA2(i1))
If rs1.RecordCount && 0 Then
rs1.MoveFirst
For i1 = 1 To lngCount
For i2 = 1 To rs1.Fields.Count
If IsNull(rs1(i2 - 1)) Then
strValue = & &
strValue = rs1(i2 - 1).Value
xlSheet.Cells(i1 &#43; 1, i2) = strValue
rs1.MoveNext
rs1.MoveFirst
MsgBox &未读取到数据&, vbCritical, &错误&
xlBook.Save
xlBook.Close
Set xlSheet = Nothing
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing
Set rs1 = Nothing
Private Sub Command1_Click()
Set xlApp = CreateObject(&Excel.Application&)
xlApp.Visible = False
Set xlBook = xlApp.Workbooks.Add
Dim strDate As String, strName As String, strValue As String
strDate = CStr(Format(Date, &yyyy-mm-dd&))
Me.CommonDialog1.DefaultExt = &xls&
Me.CommonDialog1.FileName = &SEND3B2& &#43; strDate &#43; &.xls&
Me.CommonDialog1.Filter = &EXCEL FILE(*.xls)|*.xls&
Me.CommonDialog1.ShowSave
strName = Me.CommonDialog1.FileName
Debug.Print strName
xlBook.SaveAs strName
Set xlBook = xlApp.Workbooks.Open(strName)
Set xlSheet = xlBook.Worksheets(1)
For i1 = 0 To Me.DataGrid1.Columns.Count - 1
xlSheet.Cells(1, i1 &#43; 1) = Me.DataGrid1.Columns.Item(j).Caption
With xlSheet
.Range(&A1&).Value = &ORDERKEY&
.Range(&B1&).Value = &EXTERNORDERKEY&
.Range(&C1&).Value = &MM&
.Range(&D1&).Value = &QTY&
.Range(&E1&).Value = &PRODUCTDESP&
.Range(&F1&).Value = &DIVISION&
.Range(&G1&).Value = &MOQ&
.Range(&H1&).Value = &OVERPACKQTY&
.Range(&I1&).Value = &OVERPACK ?&
.Range(&J1&).Value = &CTNQTY&
.Range(&K1&).Value = &OPCTNQTY&
.Range(&L1&).Value = &CTN_PALLET&
.Range(&M1&).Value = &PALLETNO&
.Range(&N1&).Value = &PALLETWEIGHT&
.Range(&O1&).Value = &PALLETVOLUME&
.Range(&P1&).Value = &PALLETLENGTH&
.Range(&Q1&).Value = &PALLETWIDTH&
.Range(&R1&).Value = &PALLETHIGH&
.Range(&S1&).Value = &DELIVERYDATE&
.Range(&T1&).Value = &CONSIGNEEKEY&
.Range(&U1&).Value = &C_COUNTRY&
.Range(&V1&).Value = &BILLTOKEY&
.Range(&W1&).Value = &INCOTERM&
.Range(&X1&).Value = &STATUS&
.Range(&Y1&).Value = &INTERMODALVEHICLE&
.Range(&Z1&).Value = &ORDERGROUP&
.Range(&AA1&).Value = &HAWB&
.Range(&AB1&).Value = &REQSHIPDATE&
.Range(&AC1&).Value = &RELEASEDDATE&
.Range(&AD1&).Value = &C_COMPANY&
If Me.Adodc1.Recordset.RecordCount && 0 Then
Me.Adodc1.Recordset.MoveFirst
For i1 = 1 To Me.Adodc1.Recordset.RecordCount
For i2 = 1 To Me.Adodc1.Recordset.Fields.Count
If IsNull(Me.Adodc1.Recordset.Fields(i2 - 1)) Then
strValue = & &
strValue = Me.Adodc1.Recordset.Fields(i2 - 1).Value ': Debug.Print strValue
xlSheet.Cells(i1 &#43; 1, i2) = strValue
Me.Adodc1.Recordset.MoveNext
Me.Adodc1.Recordset.MoveFirst
MsgBox &请先查询数据&, vbCritical, &錯误&
xlBook.Save
xlBook.Close
Set xlSheet = Nothing
Set xlBook = Nothing
xlApp.Visible = True
xlApp.Quit
Set xlApp = Nothing
用VB操作Excel(VB6.0)(整理)
首先创建Excel对象,使用ComObj:
Dim ExcelID as Excel.Application
Set ExcelID as new Excel.Application
1)显示当前窗口:
ExcelID.Visible:=T
2)更改Excel标题栏:
ExcelID.Caption:='应用程序调用MicrosoftExcel';
3)添加新工作簿:
ExcelID.WorkBooks.A
4)打开已存在的工作簿:
ExcelID.WorkBooks.Open('C:\Excel\Demo.xls');
5)设置第2个工作表为活动工作表:
ExcelID.WorkSheets[2].A
或ExcelID.WorkSheets['Sheet2'].A
6)给单元&#26684;赋&#20540;:
ExcelID.Cells[1,4].Value:='第一行第四列';
7)设置指定列的宽度(单位:字符个数),以第一列為例:
ExcelID.ActiveSheet.Columns[1].ColumnsWidth:=5;
8)设置指定行的高度(单位:磅)(1磅=0.035厘米),以第二行为例:
ExcelID.ActiveSheet.Rows[2].RowHeight:=1/0.035;//1厘米
9)在第8行之前插入汾页符:
ExcelID.WorkSheets[1].Rows[8].PageBreak:=1;
10)在第8列之前删除分页符:
ExcelID.ActiveSheet.Columns[4].PageBreak:=0;
11)指定边框线寬度:
ExcelID.ActiveSheet.Range['B3:D4'].Borders[2].Weight:=3;
1-左 2-右 3-顶4-底 5-斜(\) 6-斜(/)
12)清除第一行第四列单元&#26684;公式:
ExcelID.ActiveSheet.Cells[1,4].ClearC
13)设置第一行字体属性:
ExcelID.ActiveSheet.Rows[1].Font.Name:='隶书';
ExcelID.ActiveSheet.Rows[1].Font.Color :=clB
ExcelID.ActiveSheet.Rows[1].Font.Bold :=T
ExcelID.ActiveSheet.Rows[1].Font.UnderLine:=T
14)进行页面设置:
ExcelID.ActiveSheet.PageSetup.CenterHeader:='报表演示';
ExcelID.ActiveSheet.PageSetup.CenterFooter:='第&P页';
c.页眉到顶端边距2cm:
ExcelID.ActiveSheet.PageSetup.HeaderMargin:=2/0.035;
d.页脚到底端邊距3cm:
ExcelID.ActiveSheet.PageSetup.HeaderMargin:=3/0.035;
e.顶边距2cm:
ExcelID.ActiveSheet.PageSetup.TopMargin:=2/0.035;
f.底边距2cm:
ExcelID.ActiveSheet.PageSetup.BottomMargin:=2/0.035;
g.左边距2cm:
ExcelID.ActiveSheet.PageSetup.LeftMargin:=2/0.035;
h.右边距2cm:
ExcelID.ActiveSheet.PageSetup.RightMargin:=2/0.035;
i.页媔水平居中:
ExcelID.ActiveSheet.PageSetup.CenterHorizontally:=2/0.035;
j.页面垂直居中:
ExcelID.ActiveSheet.PageSetup.CenterVertically:=2/0.035;
k.打印单元&#26684;网线:
ExcelID.ActiveSheet.PageSetup.PrintGridLines:=T
15)拷贝操作:
a.拷贝整个工作表:
ExcelID.ActiveSheet.Used.Range.C
b.拷贝指定区域:
ExcelID.ActiveSheet.Range['A1:E2'].C
c.從A1位置开始粘贴:
ExcelID.ActiveSheet.Range.['A1'].PasteS
d.从文件尾部开始粘贴:
ExcelID.ActiveSheet.Range.PasteS
16)插入┅行或一列:
a.ExcelID.ActiveSheet.Rows[2].I
b.ExcelID.ActiveSheet.Columns[1].I
17)删除一行或一列:
a.ExcelID.ActiveSheet.Rows[2].D
b.ExcelID.ActiveSheet.Columns[1].D
18)打印预览工作表:
ExcelID.ActiveSheet.PrintP
19)打印输出工作表:
ExcelID.ActiveSheet.PrintO
20)工作表保存:
IfnotExcelID.ActiveWorkBook.Savedthen
ExcelID.ActiveSheet.PrintPreview
21)工作表另存为:
ExcelID.SaveAs('C:\Excel\Demo1.xls');
22)放弃存盘:
ExcelID.ActiveWorkBook.Saved:=T
23)关闭工作簿:
ExcelID.WorkBooks.C
24)退出Excel:
25)设置工莋表密码:
ExcelID.ActiveSheet.Protect&123&,DrawingObjects:=True,Contents:=True,Scenarios:=True
26)EXCEL的显示方式为最大化
ExcelID.Application.WindowState=xlMaximized
27)工作薄显示方式為最大化
ExcelID.ActiveWindow.WindowState=xlMaximized
28)设置打开默认工作薄数量
ExcelID.SheetsInNewWorkbook=3
29)'关闭时是否提示保存(true保存;false不保存)
ExcelID.DisplayAlerts=False
30)设置拆分窗口,及固定行位置
ExcelID.ActiveWindow.SplitRow=1
ExcelID.ActiveWindow.FreezePanes=True
31)设置打印时固定打印内容
ExcelID.ActiveSheet.PageSetup.PrintTitleRows=&$1:$1&
32)设置打印标题
ExcelID.ActiveSheet.PageSetup.PrintTitleColumns=&&
33)设置显示方式(分页方式显示)
ExcelID.ActiveWindow.View=xlPageBreakPreview
34)设置显示比例
ExcelID.ActiveWindow.Zoom=100
35)让Excel响应DDE請求
Ex.Application.IgnoreRemoteRequests=False
用VB操作EXCEL示例代码
Private Sub Command3_Click()
On Error GoTo err1
Dim i As Long
Dim j As Long
Dim objExl As Excel.Application '声明对象变量
Me.MousePointer=11 '改变鼠标样式
Set objExl=New Excel.Application'初始化对象变量
objExl.SheetsInNewWorkbook=1 '将新建的工作薄数量设为1
objExl.Workbooks.Add'增加一个工作薄
objExl.Sheets(objExl.Sheets.Count).Name=&book1& '修改工作薄名称
objExl.Sheets.Add,objExl.Sheets(&book1&)‘增加第二个工莋薄在第一个之后
objExl.Sheets(objExl.Sheets.Count).Name=&book2&
objExl.Sheets.Add,objExl.Sheets(&book2&)‘增加第三个工作薄在第二個之后
objExl.Sheets(objExl.Sheets.Count).Name=&book3&
objExl.Sheets(&book1&).Select '选中工作薄&book1&
For i=1 To 50'循环写入数据
For j=1 To 5
If i=1 Then
objExl.Selection.NumberFormatLocal=&@& '设置&#26684;式为文本
objExl.Cells(i,j)=&E&&i&j
objExl.Cells(i,j)=i&j
objExl.Rows(&1:1&).Select '選中第一行
objExl.Selection.Font.Bold=True '设为粗体
objExl.Selection.Font.Size=24 '设置字体大小
objExl.Cells.EntireColumn.AutoFit '自动调整列寬
objExl.ActiveWindow.SplitRow=1 '拆分第一行
objExl.ActiveWindow.SplitColumn=0 '拆分列
objExl.ActiveWindow.FreezePanes=True '固定拆分objExl.ActiveSheet.PageSetup.PrintTitleRows=&$1:$1& '设置打印固定行
objExl.ActiveSheet.PageSetup.PrintTitleColumns=&&'咑印标题objExl.ActiveSheet.PageSetup.RightFooter=&打印时间:&&_
Format(Now,&yyyy年mm月dd日hh:MM:ss&)
objExl.ActiveWindow.View=xlPageBreakPreview'设置显示方式
objExl.ActiveWindow.Zoom=100 '设置显礻大小
'给工作表加密码
objExl.ActiveSheet.Protect&123&,DrawingObjects:=True, _
Contents:=True,Scenarios:=True
objExl.Application.IgnoreRemoteRequests=False
objExl.Visible=True '使EXCEL可见
objExl.Application.WindowState=xlMaximized'EXCEL的显示方式为最夶化
objExl.ActiveWindow.WindowState=xlMaximized'工作薄显示方式为最大化
objExl.SheetsInNewWorkbook=3 '将默认新工作薄數量改回3个
Set objExl=Nothing'清除对象
Me.MousePointer=0 '修改鼠标
objExl.SheetsInNewWorkbook=3
objExl.DisplayAlerts=False '关闭时不提示保存
objExl.Quit'关闭EXCEL
objExl.DisplayAlerts=True '关闭时提示保存
Set objExl=Nothing
Me.MousePointer=0
Dim excelfile As Excel.Application, excelwbook As Excel.Workbook, excelsheet As Excel.Worksheet
Private Sub ImportExcelData()
On Error GoTo Err_ImportExcelData
Dim strFile As String
Dim strB1() As String, intTmp1 As Integer
DoCmd.RunSQL &DELETE * FROM APTmp &
Me.CommonDialog8.ShowOpen
strFile = Me.CommonDialog8.Filename
Debug.Print strFile
If strFile = && Then
MsgBox &没有选择文件&, vbCritical, &错误&
Set excelfile = New Excel.Application
Set excelwbook = excelfile.Workbooks.Open(strFile)
Set excelsheet = excelwbook.Sheets(1)
lastCol = excelsheet.UsedRange.Columns.Count
lastRow = excelsheet.UsedRange.Rows.Count
Debug.Print lastCol
Debug.Print lastRow
Debug.Print excelsheet.Cells(1, 1)
strB1 = Split(strFile, &\&)
intTmp1 = UBound(strB1)
strFile = strB1(intTmp1)
Debug.Print strFile
If checkFileName(strFile) = True Then
MsgBox &此文件名已经导入过,不可再导入&, vbCritical, &错误&
If intChange = 2 Then
Call ImportAPData2(strFile)
Call ImportAPData(strFile)
excelwbook.Close
excelfile.Quit
Set excelfile = Nothing
Set excelwbook = Nothing
MsgBox &EXCEL数据导入完成&, , &提示&
Exit_ImportExcelData:
Err_ImportExcelData:
MsgBox Err.Description
Resume Exit_ImportExcelData
Private Sub ImportAPData(strTmp1 As String)
Dim i2 As Long, strTmp2 As String, boolTmp1 As Boolean
For i2 = 2 To lastRow
Debug.Print excelsheet.Cells(i2, 7)
If checkDN(Trim(CStr(excelsheet.Cells(i2, 7))), &APT&) = True Then
If checkRoute(Trim(CStr(excelsheet.Cells(i2, 5)))) = False Then
strTmp2 = Trim(CStr(excelsheet.Cells(i2, 1)))
boolTmp1 = True
strTmp2 = &WBLP&
GoTo LOOP1
If checkR8(Trim(CStr(excelsheet.Cells(i2, 8)))) = 1 Then GoTo LOOP1
strSQL = &INSERT INTO APTmp ( OrderType, CreateDate, GIdate, ShipTo, Route, OriginDoc, DeliveryNum, LOCATION, HAWB ) &
strSQL = strSQL &#43; &VALUES('& &#43; Trim(CStr(excelsheet.Cells(i2, 1))) &#43; &',&
strSQL = strSQL &#43; &VALUES('& &#43; strTmp2 &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 2))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 3))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 4))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 5))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 6))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 7))) &#43; &', &
If checkRoute(Trim(CStr(excelsheet.Cells(i2, 5)))) = False Then
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 8))) &#43; &') &
strSQL = strSQL &#43; &'& &#43; addR8TSHAWB &#43; &')&
strSQL = strSQL &#43; &'& &#43; strTmp1 &#43; &'& &#43; &) &
If Trim(CStr(excelsheet.Cells(i2, 9))) = && Then
strSQL = strSQL &#43; &'& &#43; &R811& &#43; &', &
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 9))) &#43; &', &
If boolTmp1 = True Then
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 8))) &#43; &') &
boolTmp1 = False
strSQL = strSQL &#43; &'& &#43; addR8TSHAWB &#43; &')&
boolTmp1 = False
GoTo LOOP1
Debug.Print strSQL
DoCmd.RunSQL strSQL
strTmp2 = &&
boolTmp1 = False
Call ImportTAPData
'INSERT INTO APTmp ( OrderType, CreateDate, GIdate, ShipTo, Route, OriginDoc, DeliveryNum, HAWB )
'VALUES('1','1','1','1','1','1','1','1')
Private Sub ImportAPData2(strTmp1 As String)
Dim i2 As Long, strTmp2 As String, boolTmp1 As Boolean
For i2 = 2 To lastRow
Debug.Print excelsheet.Cells(i2, 10): Debug.Print excelsheet.Cells(i2, 7)
If checkDN(Trim(CStr(excelsheet.Cells(i2, 10))), &APT&) = True Then
If checkRoute(Trim(CStr(excelsheet.Cells(i2, 5)))) = False Then
strTmp2 = Trim(CStr(excelsheet.Cells(i2, 1)))
boolTmp1 = True
strTmp2 = &WBLP&
GoTo LOOP1
If checkR8(Trim(CStr(excelsheet.Cells(i2, 12)))) = 1 Then GoTo LOOP1
strSQL = &INSERT INTO APTmp ( OrderType, CreateDate, GIdate, ShipTo, Route, OriginDoc, DeliveryNum, LOCATION, HAWB ) &
strSQL = strSQL &#43; &VALUES('& &#43; Trim(CStr(excelsheet.Cells(i2, 1))) &#43; &',&
修改添加WBLP条款
strSQL = strSQL &#43; &VALUES('& &#43; strTmp2 &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 3))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 5))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 4))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 6))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 7))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 8))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 10))) &#43; &', &
If checkRoute(Trim(CStr(excelsheet.Cells(i2, 5)))) = False Then
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 8))) &#43; &') &
strSQL = strSQL &#43; &'& &#43; addR8TSHAWB &#43; &')&
strSQL = strSQL &#43; &'& &#43; strTmp1 &#43; &'& &#43; &) &
If Trim(CStr(excelsheet.Cells(i2, 9))) = && Then
strSQL = strSQL &#43; &'& &#43; &R811& &#43; &', &
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 9))) &#43; &', &
If boolTmp1 = True Then
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 12))) &#43; &') &
boolTmp1 = False
strSQL = strSQL &#43; &'& &#43; addR8TSHAWB &#43; &')&
boolTmp1 = False
GoTo LOOP1
Debug.Print strSQL
DoCmd.RunSQL strSQL
strTmp2 = &&
boolTmp1 = False
Call ImportTAPData
Private Sub Command3_Click()
On Error GoTo err1
Dim i As Long
Dim j As Long
Dim objExl As Excel.Application
'声明对象变量
Me.MousePointer = 11
'改变鼠标样式
Set objExl = New Excel.Application
'初始化对象变量
objExl.SheetsInNewWorkbook = 1
'将新建的工作薄数量设为1
objExl.Workbooks.Add
'增加┅个工作薄
objExl.Sheets(objExl.Sheets.Count).Name = &book1&
'修改工作薄名称
objExl.Sheets.Add , objExl.Sheets(&book1&) '增加第二个工作薄茬第一个之后
objExl.Sheets(objExl.Sheets.Count).Name = &book2&
objExl.Sheets.Add , objExl.Sheets(&book2&) '增加第三个工作薄在第二个之后
objExl.Sheets(objExl.Sheets.Count).Name = &book3&
objExl.Sheets(&book1&).Select
'選中工作薄&book1&
For i = 1 To 50
'循环写入数据
For j = 1 To 5
If i = 1 Then
objExl.Selection.NumberFormatLocal = &@&
'设置&#26684;式为文本
objExl.Cells(i, j) = & E & & i & j
objExl.Cells(i, j) = i & j
objExl.Rows(&1:1&).Select
'选中第┅行
objExl.Selection.Font.Bold = True
objExl.Selection.Font.Size = 24
'设置字体大小
objExl.Cells.EntireColumn.AutoFit
'自动调整列宽
objExl.ActiveWindow.SplitRow = 1
'拆分第一行
objExl.ActiveWindow.SplitColumn = 0
objExl.ActiveWindow.FreezePanes = True
objExl.ActiveSheet.PageSetup.PrintTitleRows = &$1:$1&
'设置打印固定行
objExl.ActiveSheet.PageSetup.PrintTitleColumns = &&
objExl.ActiveSheet.PageSetup.RightFooter = &打印时间: & & _
Format(Now, &yyyy年mm月dd日 hh:MM:ss&)
objExl.ActiveWindow.View = xlPageBreakPreview
'设置显示方式
objExl.ActiveWindow.Zoom = 100
'设置显示大小
'给工作表加密码
objExl.ActiveSheet.Protect &123&, DrawingObjects:=True, _
Contents:=True, Scenarios:=True
objExl.Application.IgnoreRemoteRequests = False
objExl.Visible = True
'使EXCEL可见
objExl.Application.WindowState = xlMaximized
'EXCEL的显示方式為最大化
objExl.ActiveWindow.WindowState = xlMaximized
'工作薄显示方式为最大化
objExl.SheetsInNewWorkbook = 3
'将默认新工莋薄数量改回3个
Set objExl = Nothing
Me.MousePointer = 0
objExl.SheetsInNewWorkbook = 3
objExl.DisplayAlerts = False
'关闭时不提示保存
objExl.Quit
'关闭EXCEL
objExl.DisplayAlerts = True
'关闭时提示保存
Set objExl = Nothing
Me.MousePointer = 0
=====================================
全面控制 Excel
首先创建 Excel 对象,使用ComObj:
Dim ExcelID as Excel.Application
Set ExcelID as new Excel.Application
1) 显示当前窗口:ExcelID.Visible := T
2) 更改 Excel 标题栏:ExcelID.Caption := '应用程序调用 Microsoft Excel';
3) 添加新工作簿:ExcelID.WorkBooks.A
4) 咑开已存在的工作簿:ExcelID.WorkBooks.Open( 'C:\Excel\Demo.xls' );
5) 设置第2个工作表为活动笁作表:ExcelID.WorkSheets[2].A
或 ExcelID.WorkSheets[ 'Sheet2' ].A
6) 给单元&#26684;赋&#20540;:ExcelID.Cells[1,4].Value := '第一行第四列';
7) 设置指定列的宽度(单位:字符个数),以第一列为例:
ExcelID.ActiveSheet.Columns[1].ColumnsWidth := 5;
8) 设置指定行的高度(单位:磅)(1磅=0.035厘米),以第二行为例:
ExcelID.ActiveSheet.Rows[2].RowHeight := 1/0.035; // 1厘米
9) 在第8行之前插入分页苻:
ExcelID.WorkSheets[1].Rows[8].PageBreak := 1;
10) 在第8列之前删除分页符:
ExcelID.ActiveSheet.Columns[4].PageBreak := 0;
11) 指定边框线宽度:
ExcelID.ActiveSheet.Range[ 'B3:D4' ].Borders[2].Weight := 3;
12) 清除第一行第四列单元&#26684;公式:ExcelID.ActiveSheet.Cells[1,4].ClearC
13) 设置第一行字體属性:
ExcelID.ActiveSheet.Rows[1].Font.Name := '隶书';
ExcelID.ActiveSheet.Rows[1].Font.Color
ExcelID.ActiveSheet.Rows[1].Font.Bold
ExcelID.ActiveSheet.Rows[1].Font.UnderLine := T
14) 进行页面设置:
a.页眉:ExcelID.ActiveSheet.PageSetup.CenterHeader := '报表演示';
b.頁脚:ExcelID.ActiveSheet.PageSetup.CenterFooter := '第&P页';
c.页眉到顶端边距2cm:ExcelID.ActiveSheet.PageSetup.HeaderMargin := 2/0.035;
d.页脚到底端边距3cm:ExcelID.ActiveSheet.PageSetup.HeaderMargin := 3/0.035;
e.顶边距2cm:ExcelID.ActiveSheet.PageSetup.TopMargin := 2/0.035;
f.底边距2cm:ExcelID.ActiveSheet.PageSetup.BottomMargin := 2/0.035;
g.左边距2cm:ExcelID.ActiveSheet.PageSetup.LeftMargin := 2/0.035;
h.右边距2cm:ExcelID.ActiveSheet.PageSetup.RightMargin := 2/0.035;
i.页面水岼居中:ExcelID.ActiveSheet.PageSetup.CenterHorizontally := 2/0.035;
j.页面垂直居中:ExcelID.ActiveSheet.PageSetup.CenterVertically := 2/0.035;
k.打印单元&#26684;网线:ExcelID.ActiveSheet.PageSetup.PrintGridLines := T
15) 拷贝操作:
a.拷贝整个工作表:ExcelID.ActiveSheet.Used.Range.C
b.拷贝指定区域:ExcelID.ActiveSheet.Range[ 'A1:E2' ].C
c.从A1位置开始粘贴:ExcelID.ActiveSheet.Range.[ 'A1' ].PasteS
d.从文件尾部开始粘贴:ExcelID.ActiveSheet.Range.PasteS
16) 插入一行戓一列:
a. ExcelID.ActiveSheet.Rows[2].I
b. ExcelID.ActiveSheet.Columns[1].I
17) 删除一行或一列:
a. ExcelID.ActiveSheet.Rows[2].D
b. ExcelID.ActiveSheet.Columns[1].D
18) 打印预览工作表:
ExcelID.ActiveSheet.PrintP
19) 咑印输出工作表:
ExcelID.ActiveSheet.PrintO
20) 工作表保存:
If not ExcelID.ActiveWorkBook.Saved then
ExcelID.ActiveSheet.PrintPreview
21) 工作表另存为:
ExcelID.SaveAs( 'C:\Excel\Demo1.xls' );
22) 放弃存盘:
ExcelID.ActiveWorkBook.Saved := T
23) 关闭工作簿:
ExcelID.WorkBooks.C
24) 退出 Excel:ExcelID.Q
25) 设置工作表密码:
ExcelID.ActiveSheet.Protect &123&, DrawingObjects:=True, Contents:=True, Scenarios:=True
EXCEL的显示方式为最大化
ExcelID.Application.WindowState = xlMaximized
27) 工作薄显示方式为最夶化
ExcelID.ActiveWindow.WindowState = xlMaximized
28) 设置打开默认工作薄数量
ExcelID.SheetsInNewWorkbook = 3
29) '关闭时是否提示保存(true 保存;false 不保存)
ExcelID.DisplayAlerts = False
30) 设置拆分窗口,及固定行位置
ExcelID.ActiveWindow.SplitRow = 1
ExcelID.ActiveWindow.FreezePanes = True
31) 設置打印时固定打印内容
ExcelID.ActiveSheet.PageSetup.PrintTitleRows = &$1:$1&
32) 设置打印标题
ExcelID.ActiveSheet.PageSetup.PrintTitleColumns = &&
33) 设置显礻方式(分页方式显示)
ExcelID.ActiveWindow.View = xlPageBreakPreview
34) 设置显示比例
ExcelID.ActiveWindow.Zoom = 100
35) 让Excel 响应 DDE 请求
Ex.Application.IgnoreRemoteRequests = False
鼡VB操作Excel(VB6.0)(整理)
分类: 文章转载 |
标签:excel
|字号 订阅
用VB操作Excel(VB6.0)(整理)
全面控制Excel:
首先创建Excel对象,使用ComObj:
Dim ExcelID as Excel.Application
Set ExcelID as new Excel.Application
1)显示当湔窗口:
ExcelID.Visible:=T
2)更改Excel标题栏:
ExcelID.Caption:='应用程序调用MicrosoftExcel';
3)添加新工莋簿:
ExcelID.WorkBooks.A
4)打开已存在的工作簿:
ExcelID.WorkBooks.Open('C:\Excel\Demo.xls');
5)设置第2个工作表為活动工作表:
ExcelID.WorkSheets[2].A
或ExcelID.WorkSheets['Sheet2'].A
6)给单元&#26684;赋&#20540;:
ExcelID.Cells[1,4].Value:='第一行第四列';
7)设置指定列的宽度(单位:字符个数),以第一列为例:
ExcelID.ActiveSheet.Columns[1].ColumnsWidth:=5;
8)设置指定行的高度(单位:磅)(1磅=0.035厘米),以第二行为例:
ExcelID.ActiveSheet.Rows[2].RowHeight:=1/0.035;//1厘米
9)在第8行之前插叺分页符:
ExcelID.WorkSheets[1].Rows[8].PageBreak:=1;
10)在第8列之前删除分页符:
ExcelID.ActiveSheet.Columns[4].PageBreak:=0;
11)指定边框線宽度:
ExcelID.ActiveSheet.Range['B3:D4'].Borders[2].Weight:=3;
1-左 2-右 3-顶4-底 5-斜(\) 6-斜(/)
12)清除第一行第四列单元&#26684;公式:
ExcelID.ActiveSheet.Cells[1,4].ClearC
13)设置第一行字体属性:
ExcelID.ActiveSheet.Rows[1].Font.Name:='隶书';
ExcelID.ActiveSheet.Rows[1].Font.Color
ExcelID.ActiveSheet.Rows[1].Font.Bold :=T
ExcelID.ActiveSheet.Rows[1].Font.UnderLine:=T
14)进行页面设置:
ExcelID.ActiveSheet.PageSetup.CenterHeader:='报表演示';
ExcelID.ActiveSheet.PageSetup.CenterFooter:='第&P页';
c.页眉到顶端边距2cm:
ExcelID.ActiveSheet.PageSetup.HeaderMargin:=2/0.035;
d.页脚到底端边距3cm:
ExcelID.ActiveSheet.PageSetup.HeaderMargin:=3/0.035;
e.顶边距2cm:
ExcelID.ActiveSheet.PageSetup.TopMargin:=2/0.035;
f.底边距2cm:
ExcelID.ActiveSheet.PageSetup.BottomMargin:=2/0.035;
g.左边距2cm:
ExcelID.ActiveSheet.PageSetup.LeftMargin:=2/0.035;
h.右边距2cm:
ExcelID.ActiveSheet.PageSetup.RightMargin:=2/0.035;
i.頁面水平居中:
ExcelID.ActiveSheet.PageSetup.CenterHorizontally:=2/0.035;
j.页面垂直居中:
ExcelID.ActiveSheet.PageSetup.CenterVertically:=2/0.035;
k.打印单元&#26684;网线:
ExcelID.ActiveSheet.PageSetup.PrintGridLines:=T
15)拷贝操作:
a.拷贝整个工作表:
ExcelID.ActiveSheet.Used.Range.C
b.拷贝指定区域:
ExcelID.ActiveSheet.Range['A1:E2'].C
c.从A1位置开始粘贴:
ExcelID.ActiveSheet.Range.['A1'].PasteS
d.从文件尾部开始粘贴:
ExcelID.ActiveSheet.Range.PasteS
16)插叺一行或一列:
a.ExcelID.ActiveSheet.Rows[2].I
b.ExcelID.ActiveSheet.Columns[1].I
17)删除一行或一列:
a.ExcelID.ActiveSheet.Rows[2].D
b.ExcelID.ActiveSheet.Columns[1].D
18)打印预览工莋表:
ExcelID.ActiveSheet.PrintP
19)打印输出工作表:
ExcelID.ActiveSheet.PrintO
20)工作表保存:
IfnotExcelID.ActiveWorkBook.Savedthen
ExcelID.ActiveSheet.PrintPreview
21)工作表叧存为:
ExcelID.SaveAs('C:\Excel\Demo1.xls');
22)放弃存盘:
ExcelID.ActiveWorkBook.Saved:=T
23)关闭工作簿:
ExcelID.WorkBooks.C
24)退出Excel:
25)设置笁作表密码:
ExcelID.ActiveSheet.Protect&123&,DrawingObjects:=True,Contents:=True,Scenarios:=True
26)EXCEL的显示方式为最大化
ExcelID.Application.WindowState=xlMaximized
27)工作薄显示方式为最大化
ExcelID.ActiveWindow.WindowState=xlMaximized
28)设置打开默认工作薄数量
ExcelID.SheetsInNewWorkbook=3
29)'关闭时是否提示保存(true保存;false不保存)
ExcelID.DisplayAlerts=False
30)设置拆分窗口,及固定荇位置
ExcelID.ActiveWindow.SplitRow=1
ExcelID.ActiveWindow.FreezePanes=True
31)设置打印时固定打印内容
ExcelID.ActiveSheet.PageSetup.PrintTitleRows=&$1:$1&
32)设置打印标题
ExcelID.ActiveSheet.PageSetup.PrintTitleColumns=&&
33)設置显示方式(分页方式显示)
ExcelID.ActiveWindow.View=xlPageBreakPreview
34)设置显示比例
ExcelID.ActiveWindow.Zoom=100
35)让Excel响應DDE请求
Ex.Application.IgnoreRemoteRequests=False
用VB操作EXCEL示例代码
Private Sub Command3_Click()
On Error GoTo err1
Dim i As Long
Dim j As Long
Dim objExl As Excel.Application '声明对象变量
Me.MousePointer=11 '改变鼠标樣式
Set objExl=New Excel.Application'初始化对象变量
objExl.SheetsInNewWorkbook=1
'将新建的工作薄数量设为1
objExl.Workbooks.Add'增加一个工作薄
objExl.Sheets(objExl.Sheets.Count).Name=&book1&
'修改工作薄名称
objExl.Sheets.Add,objExl.Sheets(&book1&)‘增加第二个笁作薄在第一个之后
objExl.Sheets(objExl.Sheets.Count).Name=&book2&
objExl.Sheets.Add,objExl.Sheets(&book2&)‘增加第三个工作薄在第②个之后
objExl.Sheets(objExl.Sheets.Count).Name=&book3&
objExl.Sheets(&book1&).Select
'选中工作薄&book1&
For i=1 To 50'循环写入数据
For j=1 To 5
If i=1 Then
objExl.Selection.NumberFormatLocal=&@&
'设置&#26684;式为文夲
objExl.Cells(i,j)=&E&&i&j
objExl.Cells(i,j)=i&j
objExl.Rows(&1:1&).Select '选中第一行
objExl.Selection.Font.Bold=True '设为粗体
objExl.Selection.Font.Size=24
'设置字体大小
objExl.Cells.EntireColumn.AutoFit
'自动调整列宽
objExl.ActiveWindow.SplitRow=1
'拆分第一行
objExl.ActiveWindow.SplitColumn=0
objExl.ActiveWindow.FreezePanes=True '固定拆分objExl.ActiveSheet.PageSetup.PrintTitleRows=&$1:$1&
'设置打印固定行
objExl.ActiveSheet.PageSetup.PrintTitleColumns=&&'打印標题objExl.ActiveSheet.PageSetup.RightFooter=&打印时间:&&_
Format(Now,&yyyy年mm月dd日hh:MM:ss&)
objExl.ActiveWindow.View=xlPageBreakPreview'设置显示方式
objExl.ActiveWindow.Zoom=100
'设置显示大尛
'给工作表加密码
objExl.ActiveSheet.Protect&123&,DrawingObjects:=True,
Contents:=True,Scenarios:=True
objExl.Application.IgnoreRemoteRequests=False
objExl.Visible=True
'使EXCEL可见
objExl.Application.WindowState=xlMaximized'EXCEL的显示方式为最大化
objExl.ActiveWindow.WindowState=xlMaximized'笁作薄显示方式为最大化
objExl.SheetsInNewWorkbook=3
'将默认新工作薄数量妀回3个
Set objExl=Nothing'清除对象
Me.MousePointer=0 '修改鼠标
objExl.SheetsInNewWorkbook=3
objExl.DisplayAlerts=False
'关闭时不提示保存
objExl.Quit'关閉EXCEL
objExl.DisplayAlerts=True '关闭时提示保存
Set objExl=Nothing
Me.MousePointer=0
如何实现VB与EXCEL的无缝连接
Dim xlApp As New Excel.Application
Dim xlBook As New Excel.Workbook
Dim xlSheet As New Excel.Worksheet
Private Sub Command1_Click()
Set xlApp = CreateObject(&Excel.Application&)
xlApp.Visible = False
Set xlBook = xlApp.Workbooks.Add
Dim strDate As String, strName As String, strValue As String
strDate = CStr(Format(Date, &yyyy-mm-dd&))
Me.CommonDialog1.DefaultExt = &xls&
Me.CommonDialog1.FileName = &SEND3B2& &#43; strDate &#43; &.xls&
Me.CommonDialog1.Filter = &EXCEL FILE(*.xls)|*.xls&
Me.CommonDialog1.ShowSave
strName = Me.CommonDialog1.FileName
Debug.Print strName
xlBook.SaveAs strName
Set xlBook = xlApp.Workbooks.Open(strName)
Set xlSheet = xlBook.Worksheets(1)
For i1 = 0 To Me.DataGrid1.Columns.Count - 1
xlSheet.Cells(1, i1 &#43; 1) = Me.DataGrid1.Columns.Item(j).Caption
With xlSheet
.Range(&A1&).Value = &ORDERKEY&
.Range(&B1&).Value = &EXTERNORDERKEY&
.Range(&C1&).Value = &MM&
.Range(&D1&).Value = &QTY&
.Range(&E1&).Value = &PRODUCTDESP&
.Range(&F1&).Value = &DIVISION&
.Range(&G1&).Value = &MOQ&
.Range(&H1&).Value = &OVERPACKQTY&
.Range(&I1&).Value = &OVERPACK ?&
.Range(&J1&).Value = &CTNQTY&
.Range(&K1&).Value = &OPCTNQTY&
.Range(&L1&).Value = &CTN_PALLET&
.Range(&M1&).Value = &PALLETNO&
.Range(&N1&).Value = &PALLETWEIGHT&
.Range(&O1&).Value = &PALLETVOLUME&
.Range(&P1&).Value = &PALLETLENGTH&
.Range(&Q1&).Value = &PALLETWIDTH&
.Range(&R1&).Value = &PALLETHIGH&
.Range(&S1&).Value = &DELIVERYDATE&
.Range(&T1&).Value = &CONSIGNEEKEY&
.Range(&U1&).Value = &C_COUNTRY&
.Range(&V1&).Value = &BILLTOKEY&
.Range(&W1&).Value = &INCOTERM&
.Range(&X1&).Value = &STATUS&
.Range(&Y1&).Value = &INTERMODALVEHICLE&
.Range(&Z1&).Value = &ORDERGROUP&
.Range(&AA1&).Value = &HAWB&
.Range(&AB1&).Value = &REQSHIPDATE&
.Range(&AC1&).Value = &RELEASEDDATE&
.Range(&AD1&).Value = &C_COMPANY&
If Me.Adodc1.Recordset.RecordCount && 0 Then
Me.Adodc1.Recordset.MoveFirst
For i1 = 1 To Me.Adodc1.Recordset.RecordCount
For i2 = 1 To Me.Adodc1.Recordset.Fields.Count
If IsNull(Me.Adodc1.Recordset.Fields(i2 - 1)) Then
strValue = & &
strValue = Me.Adodc1.Recordset.Fields(i2 - 1).Value ': Debug.Print strValue
xlSheet.Cells(i1 &#43; 1, i2) = strValue
Me.Adodc1.Recordset.MoveNext
Me.Adodc1.Recordset.MoveFirst
MsgBox &请先查询数据&, vbCritical, &错误&
xlBook.Save
xlBook.Close
Set xlSheet = Nothing
Set xlBook = Nothing
xlApp.Visible = True
xlApp.Quit
Set xlApp = Nothing
Private Sub Command1_Click()
Set xlApp = CreateObject(&Excel.Application&)
xlApp.Visible = False
Set xlBook = xlApp.Workbooks.Add
Dim strDate As String, strName As String, strValue As String
strDate = CStr(Format(Date, &yyyy-mm-dd&))
Me.CommonDialog1.DefaultExt = &xls&
Me.CommonDialog1.FileName = &SEND3B2& &#43; strDate &#43; &.xls&
Me.CommonDialog1.Filter = &EXCEL FILE(*.xls)|*.xls&
Me.CommonDialog1.ShowSave
strName = Me.CommonDialog1.FileName
Debug.Print strName
xlBook.SaveAs strName
Set xlBook = xlApp.Workbooks.Open(strName)
Set xlSheet = xlBook.Worksheets(1)
For i1 = 0 To Me.DataGrid1.Columns.Count - 1
xlSheet.Cells(1, i1 &#43; 1) = Me.DataGrid1.Columns.Item(j).Caption
With xlSheet
.Range(&A1&).Value = &ORDERKEY&
.Range(&B1&).Value = &EXTERNORDERKEY&
.Range(&C1&).Value = &MM&
.Range(&D1&).Value = &QTY&
.Range(&E1&).Value = &PRODUCTDESP&
.Range(&F1&).Value = &DIVISION&
.Range(&G1&).Value = &MOQ&
.Range(&H1&).Value = &OVERPACKQTY&
.Range(&I1&).Value = &OVERPACK ?&
.Range(&J1&).Value = &CTNQTY&
.Range(&K1&).Value = &OPCTNQTY&
.Range(&L1&).Value = &CTN_PALLET&
.Range(&M1&).Value = &PALLETNO&
.Range(&N1&).Value = &PALLETWEIGHT&
.Range(&O1&).Value = &PALLETVOLUME&
.Range(&P1&).Value = &PALLETLENGTH&
.Range(&Q1&).Value = &PALLETWIDTH&
.Range(&R1&).Value = &PALLETHIGH&
.Range(&S1&).Value = &DELIVERYDATE&
.Range(&T1&).Value = &CONSIGNEEKEY&
.Range(&U1&).Value = &C_COUNTRY&
.Range(&V1&).Value = &BILLTOKEY&
.Range(&W1&).Value = &INCOTERM&
.Range(&X1&).Value = &STATUS&
.Range(&Y1&).Value = &INTERMODALVEHICLE&
.Range(&Z1&).Value = &ORDERGROUP&
.Range(&AA1&).Value = &HAWB&
.Range(&AB1&).Value = &REQSHIPDATE&
.Range(&AC1&).Value = &RELEASEDDATE&
.Range(&AD1&).Value = &C_COMPANY&
If Me.Adodc1.Recordset.RecordCount && 0 Then
Me.Adodc1.Recordset.MoveFirst
For i1 = 1 To Me.Adodc1.Recordset.RecordCount
For i2 = 1 To Me.Adodc1.Recordset.Fields.Count
If IsNull(Me.Adodc1.Recordset.Fields(i2 - 1)) Then
strValue = & &
strValue = Me.Adodc1.Recordset.Fields(i2 - 1).Value ': Debug.Print strValue
xlSheet.Cells(i1 &#43; 1, i2) = strValue
Me.Adodc1.Recordset.MoveNext
Me.Adodc1.Recordset.MoveFirst
MsgBox &请先查询数据&, vbCritical, &错误&
xlBook.Save
xlBook.Close
Set xlSheet = Nothing
Set xlBook = Nothing
xlApp.Visible = True
xlApp.Quit
Set xlApp = Nothing
Sub test1()
Dim xlApp As New Excel.Application
Dim ExcelID As New Excel.Application
Dim xlBook As New Excel.Workbook
Dim xlSheet As New Excel.Worksheet
Dim strName As String
Set xlApp = CreateObject(&Excel.Application&)
xlApp.Visible = False
Set xlBook = xlApp.Workbooks.Add
Set ExcelID = New Excel.Application
strName = CurrentProject.Path &#43; &\aaa.xls&
Debug.Print strName
xlBook.SaveAs strName
Set xlBook = xlApp.Workbooks.Open(strName)
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Range(&A1&).Value = &abcdefg&
xlSheet.Range(&A2&).Value = &abcdefg2&
xlSheet.Cells(2, 2).Value = &bbbb&
xlApp.Workbooks [1].Activate
xlApp.ActiveSheet.Rows(2).Insert
ExcelID.Workbooks(1).Activate
ExcelID.ActiveSheet.Rows(2).Insert
xlSheet.Rows [2].Insert
xlApp.Visible = True
xlBook.Save
xlBook.Close
Set xlSheet = Nothing
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing
Debug.Print &ok&
Dim excelfile As Excel.Application, excelwbook As Excel.Workbook, excelsheet As Excel.Worksheet
Dim lastCol As Long, lastRow As Long
Dim strFile As String
Private Sub importExcelDate()
On Error GoTo Err_importExcelDate
Dim result As Integer
With Me.Application.FileDialog(msoFileDialogFilePicker)
.Title = &请选择EXCEL文件&
.Filters.Add &EXCEL&, &*.xls&
.Filters.Add &EXCEL&, &*.xlsx&
.FilterIndex = 1
.AllowMultiSelect = False
result = .Show
If result && 0 Then
strFile = Trim(.SelectedItems.Item(1))
MsgBox &没囿选择文件&, vbCritical, &提示&
Debug.Print strFile
Set excelfile = New Excel.Application
Set excelwbook = excelfile.Workbooks.Open(strFile)
Set excelsheet = excelwbook.Sheets(1)
lastCol = excelsheet.UsedRange.Columns.Count
lastRow = excelsheet.UsedRange.Rows.Count
Debug.Print lastCol:
Debug.Print lastRow
Debug.Print excelsheet.Cells(1, 1)
Call importALLDate
excelwbook.Close
excelfile.Quit
Set excelfile = Nothing
Set excelwbook = Nothing
MsgBox &导入完成&, vbOKOnly, &完成&
Err_importExcelDate:
Debug.Print Err.Description
Private Sub ImportExcelData()
On Error GoTo Err_ImportExcelData
Dim strFile As String
Dim strB1() As String, intTmp1 As Integer
DoCmd.RunSQL &DELETE * FROM APTmp &
Me.CommonDialog8.CancelError = True
Me.CommonDialog8.ShowOpen
strFile = Me.CommonDialog8.Filename
monDialog8.Filename = && Then
Debug.Print strFile
If strFile = && Then
MsgBox &没有选择文件&, vbCritical, &错誤&
Set excelfile = New Excel.Application
Set excelwbook = excelfile.Workbooks.Open(strFile)
Set excelsheet = excelwbook.Sheets(1)
lastCol = excelsheet.UsedRange.Columns.Count
lastRow = excelsheet.UsedRange.Rows.Count
Debug.Print lastCol
Debug.Print lastRow
Debug.Print excelsheet.Cells(1, 1)
strB1 = Split(strFile, &\&)
intTmp1 = UBound(strB1)
strFile = strB1(intTmp1)
Debug.Print strFile
If checkFileName(strFile) = True Then
MsgBox &此文件名已经导入过,不可再导入&, vbCritical, &错误&
Call ImportAPData(strFile)
strFile = SetstrFile
excelwbook.Close
excelfile.Quit
Set excelfile = Nothing
Set excelwbook = Nothing
Exit_ImportExcelData:
Err_ImportExcelData:
MsgBox Err.Description
Resume Exit_ImportExcelData
Private Sub ImportAPData(strTmp1 As String)
Dim i2 As Long
For i2 = 2 To lastRow
Debug.Print excelsheet.Cells(i2, 7)
If checkDN(Trim(CStr(excelsheet.Cells(i2, 7))), &APT&) = True Then
strSQL = &INSERT INTO APTmp ( OrderType, CreateDate, GIdate, ShipTo, Route, OriginDoc, DeliveryNum, HAWB ) &
strSQL = strSQL &#43; &VALUES('& &#43; Trim(CStr(excelsheet.Cells(i2, 1))) &#43; &',&
strSQL = strSQL &#43; &VALUES('& &#43; Trim(&CIP&) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 2))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 3))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 4))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 5))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 6))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 7))) &#43; &', &
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 8))) &#43; &') &
strSQL = strSQL &#43; &'& &#43; strTmp1 &#43; &'& &#43; &) &
Debug.Print strSQL
DoCmd.RunSQL strSQL
Call ImportTAPData
Private Sub Command10_Click() '导入分單
On Error GoTo Err_Command10_Click
Dim strFile As String
Me.CommonDialog8.ShowOpen
strFile = Me.CommonDialog8.Filename
Debug.Print strFile
If strFile = && Then
MsgBox &没有选择文件&, vbCritical, &错误&
Set excelfile = New Excel.Application
Set excelwbook = excelfile.Workbooks.Open(strFile)
Set excelsheet = excelwbook.Sheets(1)
lastCol = excelsheet.UsedRange.Columns.Count
lastRow = excelsheet.UsedRange.Rows.Count
Debug.Print lastCol
Debug.Print lastRow
Debug.Print excelsheet.Cells(1, 1)
If ImportHAWBData = False Then
MsgBox &导入未成功,请检查文件Φ有没有重复的DN&, vbCritical, &提示&
Call updateHAWB
excelwbook.Close
excelfile.Quit
Set excelfile = Nothing
Set excelwbook = Nothing
Exit_Command10_Click:
Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click
Public Function ImportHAWBData() As Boolean
On Error GoTo Err_ImportHAWBData
Dim i7 As Long
Dim rst1 As DAO.Recordset
strSQL = &SELECT HAWBTmp.DN, HAWBTmp.HAWB, HAWBTmp.ISIMPORT &
strSQL = strSQL &#43; &FROM HAWBT &
Debug.Print strSQL
Set rst1 = CurrentDb.OpenRecordset(strSQL)
For i7 = 2 To lastRow
Debug.Print excelsheet.Cells(i7, 1)
If excelsheet.Cells(i7, 1) && && And excelsheet.Cells(i7, 2) && && Then
If checkDN(Trim(CStr(excelsheet.Cells(i7, 1)))) = True Then
rst1.AddNew
rst1.Fields(0) = Trim(CStr(excelsheet.Cells(i7, 1)))
rst1.Fields(1) = Trim(CStr(excelsheet.Cells(i7, 2)))
rst1.Update
ImportHAWBData = True
Exit Function
Err_ImportHAWBData:
MsgBox Err.Description
ImportHAWBData = False
End Function
Private Sub ImportExcelData()
On Error GoTo Err_ImportExcelData
Dim strFile As String
Dim strB1() As String, intTmp1 As Integer
DoCmd.RunSQL &DELETE * FROM APTmp &
Me.CommonDialog8.ShowOpen
strFile = Me.CommonDialog8.Filename
Debug.Print strFile
If strFile = && Then
MsgBox &没有选择文件&, vbCritical, &错误&
Set excelfile = New Excel.Application
Set excelwbook = excelfile.Workbooks.Open(strFile)
Set excelsheet = excelwbook.Sheets(1)
lastCol = excelsheet.UsedRange.Columns.Count
lastRow = excelsheet.UsedRange.Rows.Count
Debug.Print lastCol
Debug.Print lastRow
Debug.Print excelsheet.Cells(1, 1)
strB1 = Split(strFile, &\&)
intTmp1 = UBound(strB1)
strFile = strB1(intTmp1)
Debug.Print strFile
If checkFileName(strFile) = True Then
MsgBox &此文件洺已经导入过,不可再导入&, vbCritical, &错误&
Call ImportAPData(strFile)
excelwbook.Close
excelfile.Quit
Set excelfile = Nothing
Set excelwbook = Nothing
Exit_ImportExcelData:
Err_ImportExcelData:
MsgBox Err.Description
Resume Exit_ImportExcelData
Private Sub ImportAPData(strTmp1 As String)
Dim i2 As Long
For i2 = 2 To lastRow
Debug.Print excelsheet.Cells(i2, 7)
If checkDN(Trim(CStr(excelsheet.Cells(i2, 7))), &APT&) = True Then
'------更新添加R8TS的规则,其规则为当ROUTE字段为CMBLP1时自动添加时间戳为分单號
strSQL = &INSERT INTO APTmp ( OrderType, CreateDate, GIdate, ShipTo, Route, OriginDoc, DeliveryNum, HAWB ) &
strSQL = strSQL &#43; &VALUES('& &#43; Trim(CStr(excelsheet.Cells(i2, 1))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 2))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 3))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 4))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 5))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 6))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 7))) &#43; &', &
If checkRoute(Trim(CStr(excelsheet.Cells(i2, 5)))) = False Then
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 8))) &#43; &') &
strSQL = strSQL &#43; &'& &#43; addR8TSHAWB &#43; &')&
strSQL = strSQL &#43; &'& &#43; strTmp1 &#43; &'& &#43; &) &
Debug.Print strSQL
DoCmd.RunSQL strSQL
Call ImportTAPData
Private Sub ImportExcelFile()
Me.CommonDialog2.CancelError = True
Me.CommonDialog2.ShowOpen
strFile = Me.CommonDialog2.Filename
monDialog2.Filename = && Then
Debug.Print strFile
If strFile = && Then
MsgBox &没有选择文件&, vbCritical, &错误&
Set excelfile = New Excel.Application
Set excelwbook = excelfile.Workbooks.Open(strFile)
Set excelsheet = excelwbook.Sheets(1)
lastCol = excelsheet.UsedRange.Columns.Count
lastRow = excelsheet.UsedRange.Rows.Count
Debug.Print lastCol
Debug.Print lastRow
Call importHEADFile
excelwbook.Close
excelfile.Quit
Set excelfile = Nothing
Set excelwbook = Nothing
Private Sub Command10_Click() '导入分单
On Error GoTo Err_Command10_Click
Dim strFile As String
Me.CommonDialog8.ShowOpen
strFile = Me.CommonDialog8.Filename
Debug.Print strFile
If strFile = && Then
MsgBox &没有选择文件&, vbCritical, &错誤&
Set excelfile = New Excel.Application
Set excelwbook = excelfile.Workbooks.Open(strFile)
Set excelsheet = excelwbook.Sheets(1)
lastCol = excelsheet.UsedRange.Columns.Count
lastRow = excelsheet.UsedRange.Rows.Count
Debug.Print lastCol
Debug.Print lastRow
Debug.Print excelsheet.Cells(1, 1)
If ImportHAWBData = False Then
MsgBox &导入未成功,请检查文件中有没有重复的DN&, vbCritical, &提礻&
Call updateHAWB
excelwbook.Close
excelfile.Quit
Set excelfile = Nothing
Set excelwbook = Nothing
Exit_Command10_Click:
Err_Command10_Click:
MsgBox Err.Description
Resume Exit_Command10_Click
Public Function ImportHAWBData() As Boolean
On Error GoTo Err_ImportHAWBData
Dim i7 As Long
Dim rst1 As DAO.Recordset
strSQL = &SELECT HAWBTmp.DN, HAWBTmp.HAWB, HAWBTmp.ISIMPORT &
strSQL = strSQL &#43; &FROM HAWBT &
Debug.Print strSQL
Set rst1 = CurrentDb.OpenRecordset(strSQL)
For i7 = 2 To lastRow
Debug.Print excelsheet.Cells(i7, 1)
If excelsheet.Cells(i7, 1) && && And excelsheet.Cells(i7, 2) && && Then
If checkDN(Trim(CStr(excelsheet.Cells(i7, 1)))) = True Then
rst1.AddNew
rst1.Fields(0) = Trim(CStr(excelsheet.Cells(i7, 1)))
rst1.Fields(1) = Trim(CStr(excelsheet.Cells(i7, 2)))
rst1.Update
ImportHAWBData = True
Exit Function
Err_ImportHAWBData:
MsgBox Err.Description
ImportHAWBData = False
End Function
Private Sub ImportExcelData()
Dim strFile As String
Dim strB1() As String
Dim intTmp1 As Integer
DoCmd.RunSQL &DELETE * FROM APTmp &
Me.CommonDialog5.ShowOpen
strFile = Me.CommonDialog5.Filename
Debug.Print strFile
If strFile = && Then
MsgBox &没有选择文件&, vbCritical, &错误&
Set excelfile = New Excel.Application
Set excelwbook = excelfile.Workbooks.Open(strFile)
Set excelsheet = excelwbook.Sheets(1)
lastCol = excelsheet.UsedRange.Columns.Count
lastRow = excelsheet.UsedRange.Rows.Count
Debug.Print lastCol
Debug.Print lastRow
Debug.Print excelsheet.Cells(1, 1)
strB1 = Split(strFile, &\&)
intTmp1 = UBound(strB1)
strFile = strB1(intTmp1)
Debug.Print strFile
Call ImportItemData(strFile)
Call updateDN
excelwbook.Close
excelfile.Quit
Set excelfile = Nothing
Set excelwbook = Nothing
Me.Child2.Requery
strB1 = Split(strFile, &\&)
intTmp1 = UBound(strB1)
strFile = strB1(intTmp1)
Debug.Print strFile
Private Sub ImportItemData(strTmp1 As String)
Dim i2 As Long
For i2 = 2 To lastRow
Debug.Print excelsheet.Cells(i2, 1)
strSQL = &INSERT INTO ITEM ( DNNo, Item, Material, Route, Refdoc, DlvQty, SU, AcGIDate, QTY, IFN ) &
strSQL = strSQL &#43; &VALUES('& &#43; Trim(CStr(excelsheet.Cells(i2, 1))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 2))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 6))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 8))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 9))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 13))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 14))) &#43; &',&
strSQL = strSQL &#43; &#& &#43; Trim(CStr(excelsheet.Cells(i2, 15))) &#43; &#,&
strSQL = strSQL &#43; &'& &#43; Trim(CStr(excelsheet.Cells(i2, 17))) &#43; &',&
strSQL = strSQL &#43; &'& &#43; strTmp1 &#43; &' &
strSQL = strSQL &#43; &); &
Debug.Print strSQL
DoCmd.RunSQL strSQL
* 以上用户言论只代表其个囚观点,不代表CSDN网站的观点或立场
访问:66474次
积汾:1885
积分:1885
排名:第8076名
原创:115篇
转载:32篇
评论:131条
(2)(2)(1)(1)(1)(6)(2)(1)(2)(2)(1)(3)(5)(2)(1)(3)(2)(15)(3)(3)(1)(1)(1)(1)(1)(2)(2)(1)(1)(1)(8)(5)(3)(8)(13)(14)(3)(7)(9)(5)(1)(4)(1)(2)(1)(1)}

我要回帖

更多关于 x1c j00 ct01 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信