📄 3985.html
字号:
<html>
<head>
<title>Re: Printed Access Reports From VB</title>
</head>
<body bgcolor="#FFFFFF" vlink="#808080">
<center>
<h1>Re: Printed Access Reports From VB</h1>
</center>
<hr size=7 width=75%>
<hr size=7 width=75%><p>
Posted by <a href="mailto:albertcfchen@gvc.com">Albert</a> on July 17, 1998 at 09:53:10:<p>
In Reply to: <a href="3957.html">Re: Printed Access Reports From VB</a> posted by wwd on July 16, 1998 at 15:38:40:<p>
范例: vb6 连上Excel <p>Private Sub XlsTest()<br> Dim xlApp As EXCEL.Application ‘ 注意要先按装 Excel (建议使用Office97以上版本)<br> Dim xlBook As EXCEL.Workbook<br> Dim xlSheet1 As EXCEL.Worksheet<br> Dim SQL As String<br> Dim xlsFile As String<br> <br> xlsFile = App.Path & "\test1.xls"<br> <br>‘ 以下作法 即为 “ OLE Automation “<br> Set xlApp = CreateObject("EXCEL.APPLICATION")<p> ' Set xlBook = xlApp.Workbooks.Add ‘ 新增<br> ' Set xlSheet1 = xlApp.Sheets(1) ' 相同<p> Set xlBook = xlApp.Workbooks.Open(xlsFile) ‘ 开启已存在的XLS档 <br> Set xlSheet1 = xlBook.Worksheets(1) ‘ 指定WorkSheet<br> <br> xlApp.Visible = True ' 若不需显示Excel 画面 -->False<br>' 存资料至指定的位置 (列,行)<br> xlSheet1.Cells(1, 1).Value = "AA"<br> xlSheet1.Cells(1, 2).Value = "BB"<br> xlSheet1.Cells(1, 3).Value = "CC"<p> xlSheet1.Cells(2, 1).Value = 1<br> xlSheet1.Cells(2, 2).Value = 2<br> xlSheet1.Cells(2, 3).Value = 3<br> <br> xlSheet1.Cells(3, 1).Value = 10<br> xlSheet1.Cells(3, 2).Value = 20<br> xlSheet1.Cells(3, 3).Value = 30<br> ' Row, Col<br> On Error Resume Next<p> xlSheet1.Application.SaveWorkspace ' 储存Current WorkSheet<br> ‘xlBook.Saved = True ‘ 不储存<p>' xlSheet1.PrintPreview ' 可印前预视<br>' 可指定列印第N页到第X页<br> xlSheet1.PrintOut ' from page n ,to page n <br> xlApp.Quit ' ***** 使用完毕 一定要记得关闭Excel程式<br>' Release memory<br> Set xlSheet1 = Nothing<br> Set xlBook = Nothing<br> Set xlApp = Nothing<p>End Sub<br>
<br>
<br><hr size=7 width=75%><p>
<a name="followups">Follow Ups:</a><br>
<ul><!--insert: 3985-->
</ul><!--end: 3985-->
<br><hr size=7 width=75%><p>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -