If .View.SplitSpecial = wdPaneNone Then .ActivePane.View.Type = wdNormalView End If
If Not (Rstbm.EOF And Rstbm.BOF) Then Rstbm.MoveFirst Do While Not Rstbm.EOF objWord.Selection.TypeText Text:="NO." & Rstbm.Fields("类别编号") & " " & Rstbm.Fields("部门名称") & " [ " & Me.nian & "年" & Me.yue & "月 ] 水费通知单" & Chr(13) ' .Selection.TypeText Text:="| 帐号 | 帐号 | 上期水表 | 本期水表 | 水调整量 |水倍率| 本月水量 |水单价| 应交水费 |" & "" & Chr(13) ' .Selection.TypeText Text:="-------|---------|---------|----------|---------|------|---------|------|---------|" & Chr(13)
Rsthz.Close Rsthz.Open "select * from table_单位汇总表 where 单位帐号='" & Rstbm.Fields("类别编号") & "' order by ID", adobmdb, adOpenStatic, adLockReadOnly, adCmdText
'开始调用WORD 进行打印
With objWord
.Documents.Add
End WithWith objWord.ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = CentimetersToPoints(1)
.BottomMargin = CentimetersToPoints(1)
.LeftMargin = CentimetersToPoints(1)
.RightMargin = CentimetersToPoints(1)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(0)
.FooterDistance = CentimetersToPoints(0)
.PageWidth = CentimetersToPoints(21.59)
.PageHeight = CentimetersToPoints(27.94)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterOnTop = False
.CharsLine = 47
.LinesPage = 43
End WithWith objWord.ActiveWindow
.Selection.TypeText Text:=" 中国矿业大学 水电费通知单 " & " [ " & Me.nian & "年" & Me.yue & "月 ] " & Chr(13)
.Selection.TypeText Text:=Chr(13)
'.Selection.TypeText Text:="——————————————————————————————————————————————-" & Chr(13)
WindowState = wdWindowStateMaximize
If .View.SplitSpecial = wdPaneNone Then
.ActivePane.View.Type = wdNormalView
End If
If Not (Rstbm.EOF And Rstbm.BOF) Then
Rstbm.MoveFirst
Do While Not Rstbm.EOF
objWord.Selection.TypeText Text:="NO." & Rstbm.Fields("类别编号") & " " & Rstbm.Fields("部门名称") & " [ " & Me.nian & "年" & Me.yue & "月 ] 水费通知单" & Chr(13)
' .Selection.TypeText Text:="| 帐号 | 帐号 | 上期水表 | 本期水表 | 水调整量 |水倍率| 本月水量 |水单价| 应交水费 |" & "" & Chr(13)
' .Selection.TypeText Text:="-------|---------|---------|----------|---------|------|---------|------|---------|" & Chr(13)
Rsthz.Close
Rsthz.Open "select * from table_单位汇总表 where 单位帐号='" & Rstbm.Fields("类别编号") & "' order by ID", adobmdb, adOpenStatic, adLockReadOnly, adCmdText
objWord.Selection.TypeText Text:="帐号"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="户名"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="上期水表"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="本期水表"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="水调整量"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="水倍率"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="水量"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="水价"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="水费"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=12
objWord.Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=50, RulerStyle:=wdAdjustNone
objWord.Selection.Tables(1).Columns(2).SetWidth ColumnWidth:=85, RulerStyle:=wdAdjustNone
objWord.Selection.Tables(1).Columns(6).SetWidth ColumnWidth:=50, RulerStyle:=wdAdjustNone
objWord.Selection.Tables(1).Columns(7).SetWidth ColumnWidth:=50, RulerStyle:=wdAdjustNone
objWord.Selection.Tables(1).Columns(8).SetWidth ColumnWidth:=50, RulerStyle:=wdAdjustNone
objWord.Selection.Tables(1).Columns(9).SetWidth ColumnWidth:=60, RulerStyle:=wdAdjustNone
If Not (Rsthz.EOF And Rsthz.BOF) Then
Rsthz.MoveFirst
Do While Not Rsthz.EOF
objWord.Selection.InsertRows 1
objWord.Selection.TypeText Text:=CStr(NullToString(Rsthz.Fields("ID")))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(NullToString(Rsthz.Fields("内部名称")))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Rsthz.Fields("期初水表数"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Rsthz.Fields("期末水表数"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Rsthz.Fields("水表调整数"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Rsthz.Fields("水倍率"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Rsthz.Fields("本月水量"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Format(Rsthz.Fields("水价"), "###0.00"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Rsthz.Fields("本月水费"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=12
' .Selection.TypeText Text:=Rsthz.Fields("ID") & " " & Rsthz.Fields("内部名称") & Chr(13)
Rsthz.MoveNext
Loop
End If
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=12
'objWord.Selection.TypeText Text:=Chr(13)
objWord.Selection.TypeText Text:="NO." & Rstbm.Fields("类别编号") & " " & Rstbm.Fields("部门名称") & " [ " & Me.nian & "年" & Me.yue & "月 ] 电费通知单" & Chr(13)
objWord.ActiveDocument.Tables.Add Range:=objWord.Selection.Range, NumRows:=1, NumColumns:=9
objWord.Selection.TypeText Text:="帐号"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="户名"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="上期电表"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="本期电表"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="电调整量"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="电倍率"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="电量"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="电价"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:="电费"
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=12
objWord.Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=50, RulerStyle:=wdAdjustNone
objWord.Selection.Tables(1).Columns(2).SetWidth ColumnWidth:=85, RulerStyle:=wdAdjustNone
objWord.Selection.Tables(1).Columns(6).SetWidth ColumnWidth:=50, RulerStyle:=wdAdjustNone
objWord.Selection.Tables(1).Columns(7).SetWidth ColumnWidth:=50, RulerStyle:=wdAdjustNone
objWord.Selection.Tables(1).Columns(8).SetWidth ColumnWidth:=50, RulerStyle:=wdAdjustNone
objWord.Selection.Tables(1).Columns(9).SetWidth ColumnWidth:=60, RulerStyle:=wdAdjustNone
If Not (Rsthz.EOF And Rsthz.BOF) Then
Rsthz.MoveFirst
Do While Not Rsthz.EOF
objWord.Selection.InsertRows 1
objWord.Selection.TypeText Text:=CStr(NullToString(Rsthz.Fields("ID")))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(NullToString(Rsthz.Fields("内部名称")))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Rsthz.Fields("期初电表数"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Rsthz.Fields("期末电表数"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Rsthz.Fields("电表调整数"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Rsthz.Fields("电倍率"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Rsthz.Fields("本月电量"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Format(Rsthz.Fields("电价"), "###0.00"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.TypeText Text:=CStr(Rsthz.Fields("本月电费"))
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=12
' .Selection.TypeText Text:=Rsthz.Fields("ID") & " " & Rsthz.Fields("内部名称") & Chr(13)
Rsthz.MoveNext
Loop
End If
If Not (Rsthz.EOF And Rsthz.BOF) Then
Rsthz.MoveFirst
End If
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=1
objWord.Selection.MoveRight Unit:=wdCharacter, Count:=12
objWord.Selection.TypeText Text:="应交费用: = " & Format(NullToZeo(Rsthz.Fields("应交费")), "##,###.00") & "元" & Chr(13)
objWord.Selection.TypeText Text:="———————————————— 剪 ———— 切 ———— 线 —————————————————-"
objWord.Selection.TypeText Text:=Chr(13)
objWord.Selection.TypeText Text:=Chr(13)
Rstbm.MoveNext
Loop
End If
Rsthz.Close
Rstbm.Close
End With