用VB调用的WORD的打印预览功能时,好像一定要先Add一个文档然后再调用打印预览,这样一来,当关闭打印预览功能时,文档窗口还是显示的,要手动再关闭一下,能不能在关闭打印预览的同时,关掉相应的文档窗口?源码如下:
Dim WordTemps As New Word.Application
WordTemps.Documents.Add App.Path + "\templates\安全活动.doc", False WordTemps.Selection.GoTo wdGoToBook, , , "年月日"
WordTemps.Selection.TypeText Format(dtpClassDate.Value, "yyyy年MM月dd日")
WordTemps.Selection.GoTo wdGoToBook, , , "举办部门"
WordTemps.Selection.TypeText ResolveDisplayEx(cboUnit.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "活动地点"
WordTemps.Selection.TypeText Trim(txtAddress.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "主持人"
WordTemps.Selection.TypeText Trim(txtHoldPeople.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "参加对象"
WordTemps.Selection.TypeText Trim(txtAttachPeople.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "记录人"
WordTemps.Selection.TypeText Trim(txtWriter.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "主要内容"
WordTemps.Selection.TypeText Trim(txtClassText.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "实到人数"
WordTemps.Selection.TypeText Val(txtActNums.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "缺席人数"
WordTemps.Selection.TypeText Val(txtAbsent.Text)
WordTemps.Visible = True
WordTemps.PrintPreview = True
Dim WordTemps As New Word.Application
WordTemps.Documents.Add App.Path + "\templates\安全活动.doc", False WordTemps.Selection.GoTo wdGoToBook, , , "年月日"
WordTemps.Selection.TypeText Format(dtpClassDate.Value, "yyyy年MM月dd日")
WordTemps.Selection.GoTo wdGoToBook, , , "举办部门"
WordTemps.Selection.TypeText ResolveDisplayEx(cboUnit.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "活动地点"
WordTemps.Selection.TypeText Trim(txtAddress.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "主持人"
WordTemps.Selection.TypeText Trim(txtHoldPeople.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "参加对象"
WordTemps.Selection.TypeText Trim(txtAttachPeople.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "记录人"
WordTemps.Selection.TypeText Trim(txtWriter.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "主要内容"
WordTemps.Selection.TypeText Trim(txtClassText.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "实到人数"
WordTemps.Selection.TypeText Val(txtActNums.Text)
WordTemps.Selection.GoTo wdGoToBook, , , "缺席人数"
WordTemps.Selection.TypeText Val(txtAbsent.Text)
WordTemps.Visible = True
WordTemps.PrintPreview = True
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货