'步骤4:将记录集rs中的字段名称和字段内容输出到Word,各字段之间用制表符分隔
'输出字段名称
For I = 0 To total_fields - 2
mywdapp.Selection.TypeText Text:=rs.Fields(I).Name & vbTab
Next I
'最后一个字段名称后加回车符
mywdapp.Selection.TypeText Text:=rs.Fields(total_fields - 1).Name & vbCrLf
'逐条输出字段内容
Do While Not rs.EOF
For I = 0 To total_fields - 2
tmpstr = rs.Fields(I).value
If rs.Fields(I).Name = "单价" Then
tmpstr = Format(tmpstr, "####.00")
End If
mywdapp.Selection.TypeText Text:=tmpstr & vbTab
Next I
'一条记录的最后一个字段后加回车符
mywdapp.Selection.TypeText Text:=rs.Fields(total_fields - 1).value & vbCrLf
rs.MoveNext
Loop
Dim strTask As String
If gCurGuardTask.TaskType = TaskType.BaoWei Then
strTask = "保卫"
End If
If gCurGuardTask.TaskType = TaskType.JinWei Then
strTask = "警卫"
End If
.Execute FindText:="JW", replacewith:=Trim(strTask), Replace:=wdReplaceAll
Dim strXH() As String
strXH = Split(Trim(Me.cboRecordSequence.Text), "―")
.Execute FindText:="XH", replacewith:=strXH(UBound(strXH)), Replace:=wdReplaceAll
'.Execute FindText:="CONTENT", replacewith:=gcurGuardRecorder.Content, Replace:=wdReplaceAll
End With
With vsWordApp.Selection.Find
.Text = "CONTENT"
.Wrap = wdFindContinue
.Execute
If UCase(vsWordApp.Selection) = "CONTENT" Then
vsWordApp.Selection.Text = gcurGuardRecorder.Content
End If
vsWordApp.Selection.HomeKey Unit:=wdStory
End With
With vsWordApp.Selection.Find
.Text = "YM"
.Wrap = wdFindContinue
.Execute
If UCase(vsWordApp.Selection) = "YM" Then
' vsWordApp.Selection.Text = CStr(vsWordApp.Selection.HeaderFooter.PageNumbers.Count + 1)
End If
End With