领星动网编程开发之爆炸小宇宙

cnitblog.com/lxasp - - 有一种信念叫做编程
posts - 61, comments - 34, trackbacks - 0, articles - 0

VB6控制EXCEL进行打印

Posted on 2012-08-07 23:56 lxasp 阅读(518) 评论(0)  编辑 收藏 引用

 

Private Sub Command1_Click()

Dim xlApp
Dim xlBook
Dim xlSheet
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)


xlSheet.Cells(
11).Value = "测试"

xlApp.Visible 
= True

xlBook.PrintOut Preview:
=1
xlBook.Close 
False
xlApp.Quit

Set xlApp = Nothing

End Sub


 

 

Function 打印Excel(EXCEL文件 As String, 定义名称Sz, 值Sz)
'
Dim i As Integer
For i = 0 To UBound(定义名称Sz)
    Application.Names(定义名称Sz(i)).RefersToRange.Value 
= 值Sz(i)
Next
Dim Sheet As Worksheet
Set Sheet = Application.ActiveSheet
'Sheet.PrintOut
End Function



相关链接:
http://hi.baidu.com/blueideanet/blog/item/563b8a605d5d23da8cb10d62.html

只有注册用户登录后才能发表评论。