代码:
Private Sub CmdPrint_Click()
Dim str As String
Dim newDoc As Object
Dim i, n As Integer
On Error GoTo errOut
frmWait.Show
str = App.Path + "\评标专家组\"
' 调用Word
Set newDoc = CreateObject("Word.Application")
Dim rngFormat As Range
newDoc.Documents.Add 'Open FileName:=str, Visible:=True
Set rngFormat = ActiveDocument.Range(Start:=0, End:=0)
With rngFormat
.InsertAfter Text:=project + "评标专家组成员:"
.InsertParagraphAfter
.InsertParagraphAfter
With .Font
.Name = "宋体"
.Size = 18
.Bold = True
End With
End With
Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(1).Range.End, End:=newDoc.Documents(1).Range.End)
With rngFormat
.InsertAfter Text:="1、管理人员:"
.InsertParagraphAfter
With .Font
.Name = "宋体"
.Size = 16
End With
End With
n = ListXM.ListCount
Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(3).Range.End, End:=newDoc.Documents(1).Range.End)
With rngFormat
For i = 0 To n - 1
If i = 0 Then .InsertAfter Text:=Space(8)
.InsertAfter Text:=ListXM.List(i)
.InsertAfter Text:=Space(4)
With .Font
.Name = "宋体"
.Size = 14
End With
Next
.InsertParagraphAfter
End With
Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(4).Range.End, End:=newDoc.Documents(1).Range.End)
With rngFormat
.InsertAfter Text:="2、技术人员:"
.InsertParagraphAfter
With .Font
.Name = "宋体"
.Size = 16
End With
End With
n = ListJS.ListCount
Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(5).Range.End, End:=newDoc.Documents(1).Range.End)
With rngFormat
For i = 0 To n - 1
If i = 0 Then .InsertAfter Text:=Space(8)
.InsertAfter Text:=ListJS.List(i)
.InsertAfter Text:=Space(4)
With .Font
.Name = "宋体"
.Size = 14
End With
Next
.InsertParagraphAfter
.InsertParagraphAfter
.InsertParagraphAfter
End With
Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(8).Range.End, End:=newDoc.Documents(1).Range.End)
With rngFormat
.InsertAfter Text:=Space(50)
.InsertAfter Text:=Date + Time
With .Font
.Name = "宋体"
.Size = 12
End With
End With
ActiveDocument.SaveAs FileName:=str + project + "评标专家组成员"
ActiveDocument.PrintOut Range:=wdPrintCurrentPage
' 关闭文件,关闭Word
newDoc.Documents(1).Close
newDoc.Quit
Set rngFormat = Nothing
Set newDoc = Nothing
Exit Sub
errOut:
Unload frmWait
MsgBox Err.Description, vbCritical, "错误"
End Sub在本机上调试通过,并用wise installation system 9.02打包在装有Win98的机子上安装后,运行出现“自动化错误”,两台机子都装的是Office XP,但是在其他装有Win2000的机子上就可以运行,我的系统是WinXP home版。请教!
Private Sub CmdPrint_Click()
Dim str As String
Dim newDoc As Object
Dim i, n As Integer
On Error GoTo errOut
frmWait.Show
str = App.Path + "\评标专家组\"
' 调用Word
Set newDoc = CreateObject("Word.Application")
Dim rngFormat As Range
newDoc.Documents.Add 'Open FileName:=str, Visible:=True
Set rngFormat = ActiveDocument.Range(Start:=0, End:=0)
With rngFormat
.InsertAfter Text:=project + "评标专家组成员:"
.InsertParagraphAfter
.InsertParagraphAfter
With .Font
.Name = "宋体"
.Size = 18
.Bold = True
End With
End With
Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(1).Range.End, End:=newDoc.Documents(1).Range.End)
With rngFormat
.InsertAfter Text:="1、管理人员:"
.InsertParagraphAfter
With .Font
.Name = "宋体"
.Size = 16
End With
End With
n = ListXM.ListCount
Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(3).Range.End, End:=newDoc.Documents(1).Range.End)
With rngFormat
For i = 0 To n - 1
If i = 0 Then .InsertAfter Text:=Space(8)
.InsertAfter Text:=ListXM.List(i)
.InsertAfter Text:=Space(4)
With .Font
.Name = "宋体"
.Size = 14
End With
Next
.InsertParagraphAfter
End With
Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(4).Range.End, End:=newDoc.Documents(1).Range.End)
With rngFormat
.InsertAfter Text:="2、技术人员:"
.InsertParagraphAfter
With .Font
.Name = "宋体"
.Size = 16
End With
End With
n = ListJS.ListCount
Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(5).Range.End, End:=newDoc.Documents(1).Range.End)
With rngFormat
For i = 0 To n - 1
If i = 0 Then .InsertAfter Text:=Space(8)
.InsertAfter Text:=ListJS.List(i)
.InsertAfter Text:=Space(4)
With .Font
.Name = "宋体"
.Size = 14
End With
Next
.InsertParagraphAfter
.InsertParagraphAfter
.InsertParagraphAfter
End With
Set rngFormat = ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(8).Range.End, End:=newDoc.Documents(1).Range.End)
With rngFormat
.InsertAfter Text:=Space(50)
.InsertAfter Text:=Date + Time
With .Font
.Name = "宋体"
.Size = 12
End With
End With
ActiveDocument.SaveAs FileName:=str + project + "评标专家组成员"
ActiveDocument.PrintOut Range:=wdPrintCurrentPage
' 关闭文件,关闭Word
newDoc.Documents(1).Close
newDoc.Quit
Set rngFormat = Nothing
Set newDoc = Nothing
Exit Sub
errOut:
Unload frmWait
MsgBox Err.Description, vbCritical, "错误"
End Sub在本机上调试通过,并用wise installation system 9.02打包在装有Win98的机子上安装后,运行出现“自动化错误”,两台机子都装的是Office XP,但是在其他装有Win2000的机子上就可以运行,我的系统是WinXP home版。请教!
解决方案 »
- 关于全局变量
- 用Set ex = CreateObject("Excel.Application")时,提示activeX部件不能创建对象
- 如何用VB关闭“Print Spooler”服务?又如何禁止这个服务?
- 条形码程序为何不能运行?网上找的代码复制到VB里,跟踪测试一点反应都没有。不知我错在哪里?
- 如何把字符串拆分开成几个字符?
- 在针式打印机上打印发票的问题
- 如何让程序在输入法旁边生成快捷方式
- 急招VB+SQL Server开发顾问
- 删除图片框中的线!答对者重重加分(100)
- Textbox的问题
- 大家看看这个问题,KEYPRESS后TEXTBOX的值的变化问题
- 怎样将查询结果导出到商务通之类的外设中呢
解決:在Win98下安裝一個Office Xp或Word Xp
'.10 为WordXP
是啊,我填的是200分,结果被警告说最多只能给100分……