VBA 为什么用VBA打开了二个WORD并打印它们,但实际上只打印了第一个WORD,谢谢

ygxshanghai 2012-08-07 10:35:04
Private Sub Command1_Click()

Dim Ap As Word.Application
Dim newDoc As Document
Set Ap = CreateObject("word.application")
Ap.Visible = True
Set newDoc = Ap.Documents.Add
....
newDoc.SaveAs App.Path & "\AAAAAA.doc"
For i = 1 To 3
ActiveDocument.PrintOut
Next i
newDoc.Close
Ap.Quit
Set Ap = Nothing '消灭对象变量
Set newDoc = Nothing



Dim objWDApp As New Word.Application
Dim objDoc As New Word.Document
Dim strTitle As String
Set objDoc = objWDApp.Documents.Add
.....
objDoc.SaveAs App.Path & "\BBBBBB.doc"
For i = 1 To 3
ActiveDocument.PrintOut
Next i
objDoc.Close
objWDApp.Quit
Set objWDApp = Nothing '消灭对象变量
Set objDoc = Nothing


End Sub
...全文
110 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ygxshanghai 2012-08-09
  • 打赏
  • 举报
回复

newDoc.ActiveDocument.PrintOut
objDoc.ActiveDocument.PrintOut
吗?
ygxshanghai 2012-08-09
  • 打赏
  • 举报
回复

newDoc.ActiveDocument.PrintOut
objDoc.ActiveDocument.PrintOut
吗?
Jia_H 2012-08-09
  • 打赏
  • 举报
回复
是newDoc.PrintOut和objDoc.PrintOut。自己试试不就行了,还来问。
Jia_H 2012-08-08
  • 打赏
  • 举报
回复
不要用ActiveDocument,用你保存的newDoc和objDoc对象。

2,503

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧