九九热最新网址,777奇米四色米奇影院在线播放,国产精品18久久久久久久久久,中文有码视频,亚洲一区在线免费观看,国产91精品在线,婷婷丁香六月天

歡迎來到裝配圖網(wǎng)! | 幫助中心 裝配圖網(wǎng)zhuangpeitu.com!
裝配圖網(wǎng)
ImageVerifierCode 換一換
首頁 裝配圖網(wǎng) > 資源分類 > DOC文檔下載  

vb控制打印機(jī)自動打印表格.doc

  • 資源ID:8973476       資源大?。?span id="24d9guoke414" class="font-tahoma">219.50KB        全文頁數(shù):15頁
  • 資源格式: DOC        下載積分:9.9積分
快捷下載 游客一鍵下載
會員登錄下載
微信登錄下載
三方登錄下載: 微信開放平臺登錄 支付寶登錄   QQ登錄   微博登錄  
二維碼
微信掃一掃登錄
下載資源需要9.9積分
郵箱/手機(jī):
溫馨提示:
用戶名和密碼都是您填寫的郵箱或者手機(jī)號,方便查詢和重復(fù)下載(系統(tǒng)自動生成)
支付方式: 支付寶    微信支付   
驗(yàn)證碼:   換一換

 
賬號:
密碼:
驗(yàn)證碼:   換一換
  忘記密碼?
    
友情提示
2、PDF文件下載后,可能會被瀏覽器默認(rèn)打開,此種情況可以點(diǎn)擊瀏覽器菜單,保存網(wǎng)頁到桌面,就可以正常下載了。
3、本站不支持迅雷下載,請使用電腦自帶的IE瀏覽器,或者360瀏覽器、谷歌瀏覽器下載即可。
4、本站資源下載后的文檔和圖紙-無水印,預(yù)覽文檔經(jīng)過壓縮,下載后原文更清晰。
5、試題試卷類文檔,如果標(biāo)題沒有明確說明有答案則都視為沒有答案,請知曉。

vb控制打印機(jī)自動打印表格.doc

VB控制EXCLE自動打印表格VB是常用的應(yīng)用軟件開發(fā)工具之一,由于VB的報(bào)表功能有限,而且一但報(bào)表格式發(fā)生變化,就得相應(yīng)修改程序,給應(yīng)用軟件的維護(hù)工作帶來極大的不便。因此充分利用EXECL的強(qiáng)大報(bào)表功來實(shí)現(xiàn)報(bào)表功能。但由于VB與EXCEL由于分別屬于不同的應(yīng)用系統(tǒng),如何把它們有機(jī)地結(jié)合在一起,是一個值得我們研究的課題。一、 VB讀寫EXCEL表:VB本身提自動化功能可以讀寫EXCEL表,其方法如下:1、在工程中引用Microsoft Excel類型庫:從"工程"菜單中選擇"引用"欄;選擇Microsoft Excel 9.0 Object Library(EXCEL2003),然后選擇"確定"。表示在工程中要引用EXCEL類型庫。2、在通用對象的聲明過程中定義EXCEL對象:Dim excel As ObjectDim workbook As ObjectDim sheet As Object3、在程序中操作EXCEL表常用命令:Set xlApp = CreateObject("Excel.Application") 創(chuàng)建EXCEL對象Set xlBook = xlApp.Workbooks.Open("文件名") 打開已經(jīng)存在的EXCEL工件簿文件xlApp.Visible = True 設(shè)置EXCEL對象可見(或不可見)Set xlSheet = xlBook.Worksheets("表名") 設(shè)置活動工作表xlSheet.Cells(row, col) =值 給單元格(row,col)賦值xlSheet.PrintOut 打印工作表xlBook.Close (True) 關(guān)閉工作簿xlApp.Quit 結(jié)束EXCEL對象Set xlApp = Nothing 釋放xlApp對象xlBook.RunAutoMacros (xlAutoOpen) 運(yùn)行EXCEL啟動宏xlBook.RunAutoMacros (xlAutoClose) 運(yùn)行EXCEL關(guān)閉宏4、在運(yùn)用以上VB命令操作EXCEL表時,除非設(shè)置EXCEL對象不可見,否則VB程序可繼續(xù)執(zhí)行其它操作,也能夠關(guān)閉EXCEL,同時也可對EXCEL進(jìn)行操作。但在EXCEL操作過程中關(guān)閉EXCEL對象時,VB程序無法知道,如果此時使用EXCEL對象,則VB程序會產(chǎn)生自動化錯誤。形成VB程序無法完全控制EXCEL的狀況,使得VB與EXCEL脫節(jié)。二、 EXCEL的宏功能:EXCEL提供一個Visual Basic編輯器,打開Visual Basic編輯器,其中有一工程屬性窗口,點(diǎn)擊右鍵菜單的"插入模塊",則增加一個"模塊1",在此模塊中可以運(yùn)用Visual Basic語言編寫函數(shù)和過程并稱之為宏。其中,EXCEL有兩個自動宏:一個是啟動宏(Sub Auto_Open()),另一個是關(guān)閉宏(Sub Auto_Close())。它們的特性是:當(dāng)用EXCEL打含有啟動宏的工簿時,就會自動運(yùn)行啟動宏,同理,當(dāng)關(guān)閉含有關(guān)閉宏的工作簿時就會自動運(yùn)行關(guān)閉宏。但是通過VB的自動化功能來調(diào)用EXCEL工作表時,啟動宏和關(guān)閉宏不會自動運(yùn)行,而需要在VB中通過命令xlBook.RunAutoMacros (xlAutoOpen)和xlBook.RunAutoMacros (xlAutoClose) 來運(yùn)行啟動宏和關(guān)閉宏。三、 VB與EXCEL的相互勾通:充分利用EXCEL的啟動宏和關(guān)閉宏,可以實(shí)現(xiàn)VB與EXCEL的相互勾通,其方法如下:在EXCEL的啟動宏中加入一段程序,其功能是在磁盤中寫入一個標(biāo)志文件,同時在關(guān)閉宏中加入一段刪除此標(biāo)志文件的程序。VB程序在執(zhí)行時通過判斷此標(biāo)志文件存在與否來判斷EXCEL是否打開,如果此標(biāo)志文件存在,表明EXCEL對象正在運(yùn)行,應(yīng)該禁止其它程序的運(yùn)行。如果此標(biāo)志文件不存在,表明EXCEL對象已被用戶關(guān)閉,此時如果要使用EXCEL對象運(yùn)行,必須重新創(chuàng)建EXCEL對象。四、VB控制EXCLE自動打印表格:1、在VB中,建立一個FORM2,界面如下:其中要求輸入的參數(shù)是原表格的縱列,即A列對應(yīng)1、B列對應(yīng)2、A列對應(yīng)1、C列對應(yīng)3、D列對應(yīng)4、E列對應(yīng)5,依此類推,打印時間是控制每打一張表所須時間,單位為毫秒(ms)。當(dāng)把值設(shè)為0時,對應(yīng)單元格的內(nèi)容不變,以便靈活應(yīng)用,須把要打印的表放到C盤,放到別處須要改變程序。然后在其中輸入如下程序:Option Explicit Public uint As Integer 單位名稱 Public goods As Integer 設(shè)備名稱 Public number As Integer 設(shè)備編號 Public address As Integer 出廠地址 Public modle As Integer 設(shè)備型號 Public reference As Integer 參考 Public result As Integer 檢定結(jié)果 Public dates As Integer 檢定日期 Public death As Integer 檢定日期 Public cel As Integer 打印張數(shù) Public time As Integer 打印時間Private Sub Command1_Click() Form2.Hide Form1.ShowEnd SubPrivate Sub Command3_Click() uint = Val(Text1.Text) 單位名稱 goods = Val(Text2.Text) 設(shè)備名稱 modle = Val(Text3.Text) 設(shè)備型號 address = Val(Text4.Text) 出廠地址 number = Val(Text5.Text) 設(shè)備編號 reference = Val(Text6.Text) 參考 result = Val(Text7.Text) 檢定結(jié)果 dates = Val(Text8.Text) 檢定日期 time = Val(Text9.Text) 打印時間 death = Val(Text10.Text) 有效期至 MsgBox "!- 參數(shù)修改成功-!"End SubPrivate Sub Form_Initialize() 數(shù)據(jù)初始化 cel = 1 打印張數(shù) uint = 1 單位名稱 goods = 2 設(shè)備名稱 number = 3 設(shè)備編號 address = 4 出廠地址 modle = 5 設(shè)備型號 reference = 6 參考 result = 7 檢定結(jié)果 dates = 8 檢定日期 death = 9 有效期至 time = 2000 打印時間間隔End SubPrivate Sub Command2_Click()EndEnd Sub建立一個FORM1,界面如下:然后在其中輸入如下程序:Dim excel As ObjectDim workbook As ObjectDim sheet As ObjectDim present%Private Sub Command1_Click() 打開EXCLE表格 If Dir("C:excel.bz") = "" Then Set excel = CreateObject("excel.application") Set workbook = excel.Workbooks.Open("c:自動打印表格.xls") Set sheet = workbook.WorkSheets excel.Visible = True workbook.Application.Run "auto_open" excel.WorkSheets(2).Activate 設(shè)置表2為活動表 If Form2.uint <> 0 Then sheet(2).Cells(1, 2) = sheet(1).Cells(Form2.cel, Form2.uint) 單位名稱 If Form2.goods <> 0 Then sheet(2).Cells(2, 2) = sheet(1).Cells(Form2.cel, Form2.goods) 產(chǎn)品名稱 If Form2.number <> 0 Then sheet(2).Cells(3, 3) = sheet(1).Cells(Form2.cel, Form2.number) 設(shè)備編號 If Form2.address <> 0 Then sheet(2).Cells(4, 2) = sheet(1).Cells(Form2.cel, Form2.address) 設(shè)備廠址 If Form2.modle <> 0 Then sheet(2).Cells(5, 2) = sheet(1).Cells(Form2.cel, Form2.modle) 設(shè)備型號 If Form2.reference <> 0 Then sheet(2).Cells(6, 2) = sheet(1).Cells(Form2.cel, Form2.reference) 分度號 If Form2.result <> 0 Then sheet(2).Cells(7, 2) = sheet(1).Cells(Form2.cel, Form2.result) 檢定結(jié)果 If Form2.dates <> 0 Then sheet(2).Cells(11, 2) = sheet(1).Cells(Form2.cel, Form2.dates) 檢定日期 If Form2.death <> 0 Then sheet(2).Cells(12, 3) = sheet(1).Cells(Form2.cel, Form2.death) 有效期至 Else MsgBox "EXCL已打開!" End IfEnd SubPrivate Sub Command2_Click() 關(guān)閉退出表格 If Dir("C:excel.bz") <> "" Then workbook.Application.Run "auto_close" Set excel = Nothing workbook.Close (True) End If Form1.Hide Form2.ShowEnd SubPrivate Sub Command3_Click() 暫停打印 If Dir("C:excel.bz") = "" Then MsgBox "!-請打開要打印的表格-!" Else Timer1.Enabled = False MsgBox "!-打印暫停-!" & Chr(10) & "!-已打印" & Form2.cel - present - 1 & "張-!" End IfEnd SubPrivate Sub Command4_Click() 繼續(xù)打印 If Dir("C:excel.bz") = "" Then MsgBox "!-請打開要打印的表格-!" Else Timer1.Interval = Form2.time Timer1.Enabled = True End IfEnd SubPrivate Sub Command5_Click() 開始打印 If Dir("C:excel.bz") = "" Then MsgBox "!-請打開要打印的表格-!" Else present = 0 Form2.cel = 1 Timer1.Interval = Form2.time Timer1.Enabled = True End IfEnd SubPrivate Sub Command6_Click() 下一張 If Dir("C:excel.bz") = "" Then MsgBox "!-請打開要打印的表格-!" Else present = present + 1 If Form2.uint <> 0 Then sheet(2).Cells(1, 2) = sheet(1).Cells(present, Form2.uint) 單位名稱 If Form2.goods <> 0 Then sheet(2).Cells(2, 2) = sheet(1).Cells(present, Form2.goods) 產(chǎn)品名稱 If Form2.number <> 0 Then sheet(2).Cells(3, 3) = sheet(1).Cells(present, Form2.number) 設(shè)備編號 If Form2.address <> 0 Then sheet(2).Cells(4, 2) = sheet(1).Cells(present, Form2.address) 設(shè)備廠址 If Form2.modle <> 0 Then sheet(2).Cells(5, 2) = sheet(1).Cells(present, Form2.modle) 設(shè)備型號 If Form2.reference <> 0 Then sheet(2).Cells(6, 2) = sheet(1).Cells(present, Form2.reference) 分度號 If Form2.result <> 0 Then sheet(2).Cells(7, 2) = sheet(1).Cells(present, Form2.result) 檢定結(jié)果 If Form2.dates <> 0 Then sheet(2).Cells(11, 2) = sheet(1).Cells(present, Form2.dates) 檢定日期 If Form2.death <> 0 Then sheet(2).Cells(12, 3) = sheet(1).Cells(present, Form2.death) 有效期至 End IfEnd SubPrivate Sub Command7_Click() 上一張 If Dir("C:excel.bz") = "" Then MsgBox "!-請打開要打印的表格-!" Else present = present - 1 If present <= 0 Then present = 1 If Form2.uint <> 0 Then sheet(2).Cells(1, 2) = sheet(1).Cells(present, Form2.uint) 單位名稱 If Form2.goods <> 0 Then sheet(2).Cells(2, 2) = sheet(1).Cells(present, Form2.goods) 產(chǎn)品名稱 If Form2.number <> 0 Then sheet(2).Cells(3, 3) = sheet(1).Cells(present, Form2.number) 設(shè)備編號 If Form2.address <> 0 Then sheet(2).Cells(4, 2) = sheet(1).Cells(present, Form2.address) 設(shè)備廠址 If Form2.modle <> 0 Then sheet(2).Cells(5, 2) = sheet(1).Cells(present, Form2.modle) 設(shè)備型號 If Form2.reference <> 0 Then sheet(2).Cells(6, 2) = sheet(1).Cells(present, Form2.reference) 分度號 If Form2.result <> 0 Then sheet(2).Cells(7, 2) = sheet(1).Cells(present, Form2.result) 檢定結(jié)果 If Form2.dates <> 0 Then sheet(2).Cells(11, 2) = sheet(1).Cells(present, Form2.dates) 檢定日期 If Form2.death <> 0 Then sheet(2).Cells(12, 3) = sheet(1).Cells(present, Form2.death) 有效期至 End IfEnd SubPrivate Sub Command8_Click() 從當(dāng)錢頁打印 If Dir("C:excel.bz") = "" Then MsgBox "!-請打開要打印的表格-!" Else Form2.cel = present Timer1.Enabled = True End IfEnd SubPrivate Sub Form_Load() present = 0 Timer1.Interval = Form2.time Timer1.Enabled = FalseEnd SubPrivate Sub Timer1_Timer()Dim a$ Timer1.Enabled = False a = sheet(1).Cells(Form2.cel, 2) 如果單位名稱為“”則打印結(jié)束 If a <> "" Then If Form2.uint <> 0 Then sheet(2).Cells(1, 2) = sheet(1).Cells(Form2.cel, Form2.uint) 單位名稱 If Form2.goods <> 0 Then sheet(2).Cells(2, 2) = sheet(1).Cells(Form2.cel, Form2.goods) 產(chǎn)品名稱 If Form2.number <> 0 Then sheet(2).Cells(3, 3) = sheet(1).Cells(Form2.cel, Form2.number) 設(shè)備編號 If Form2.address <> 0 Then sheet(2).Cells(4, 2) = sheet(1).Cells(Form2.cel, Form2.address) 設(shè)備廠址 If Form2.modle <> 0 Then sheet(2).Cells(5, 2) = sheet(1).Cells(Form2.cel, Form2.modle) 設(shè)備型號 If Form2.reference <> 0 Then sheet(2).Cells(6, 2) = sheet(1).Cells(Form2.cel, Form2.reference) 分度號 If Form2.result <> 0 Then sheet(2).Cells(7, 2) = sheet(1).Cells(Form2.cel, Form2.result) 檢定結(jié)果 If Form2.dates <> 0 Then sheet(2).Cells(11, 2) = sheet(1).Cells(Form2.cel, Form2.dates) 檢定日期 If Form2.death <> 0 Then sheet(2).Cells(12, 3) = sheet(1).Cells(Form2.cel, Form2.death) 有效期至 excel.ActiveSheet.PrintOut 打印輸出 Form2.cel = Form2.cel + 1 Timer1.Interval = Form2.time Timer1.Enabled = True Else MsgBox "!-表格已打完-!" & Chr(10) & "!-共打印" & Form2.cel - present - 1 & "張-!" End IfEnd Sub4、運(yùn)行VB程序,輸入?yún)?shù)點(diǎn)擊確定按鈕可完成參數(shù)的修改,打印時間是控制每打一張表所須時間,打開EXCEL系統(tǒng)后,VB程序和EXCEL分別屬兩個不同的應(yīng)用系統(tǒng),均可同時進(jìn)行操作,由于系統(tǒng)加了判斷,因此在VB程序中重復(fù)點(diǎn)擊EXCEL按鈕時會提示EXCEL已打開。如果在EXCEL中關(guān)閉EXCEL后再點(diǎn)EXCEL按鈕,則會重新打開EXCEL。而無論EXCEL打開與否,通過VB程序均可關(guān)閉EXCEL。這樣就實(shí)現(xiàn)了VB與EXCEL的無縫連接。

注意事項(xiàng)

本文(vb控制打印機(jī)自動打印表格.doc)為本站會員(wux****ua)主動上傳,裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對上載內(nèi)容本身不做任何修改或編輯。 若此文所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng)(點(diǎn)擊聯(lián)系客服),我們立即給予刪除!

溫馨提示:如果因?yàn)榫W(wǎng)速或其他原因下載失敗請重新下載,重復(fù)下載不扣分。




關(guān)于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權(quán)所有   聯(lián)系電話:18123376007

備案號:ICP2024067431-1 川公網(wǎng)安備51140202000466號


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務(wù)平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權(quán)或隱私,請立即通知裝配圖網(wǎng),我們立即給予刪除!