’報(bào)表期別
WdApp.Selection.TypeText (BbDate)
WdApp.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
WdApp.Selection.TypeParagraph
WdApp.Selection.TypeParagraph
’生成列頭
’wdApp.Selection.HomeKey wdLine, wdExtend
’dApp.Selection.Font.Bold = wdToggle
WdApp.ActiveDocument.Tables.Add WdApp.Selection.Range, rowMax, colMax
Dim i As Integer
Do
For colloop = 0 To colMax - 1
WdApp.Selection.Font.Size = 9
If i = 0 Then
’表格中標(biāo)題加粗顯示
WdApp.Selection.Font.Bold = wdToggle’表格標(biāo)題行背景顏色設(shè)置為灰色,灰度為30
With WdApp.Selection.Cells
With .Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorGray30
End With
End With
End If
’最后一行右對齊,其余左對齊
If i > 0 Then
If MyRecord.Fields.Item(colloop).Name = "ZBMC" Or MyRecord.Fields.Item(colloop).Name = "指標(biāo)名稱" Then
WdApp.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
Else
WdApp.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
End If
End If
If i = 0 And (MyRecord.Fields.Item(colloop).Name = "SXH" Or MyRecord.Fields.Item(colloop).Name = "順序號") Then
WdApp.Selection.TypeText ("序號")
Else
WdApp.Selection.TypeText (CStr(MyRecord.Fields.Item(colloop).value))
End If
If (i <> rowMax - 1 Or (i = rowMax - 1 And colloop < colMax - 1)) Then
WdApp.Selection.MoveRight (wdcell)
End If
Next
i = i + 1
MyRecord.MoveNext
Loop Until MyRecord.EOF
WdApp.ActiveDocument.SaveAs DocFileName, 0, False, "", True, "", False, False, False, False, False
WdApp.Quit
SaveAsWord = 1
Exit Function
Err_All:
Set WdApp = Nothing
SaveAsWord = -1
OutMessage = err.Description
Exit Function
End Function
好了,到此為止,我想你們對在VB中利用Word宏命令開發(fā)ASP組件,有了一些了解。只要多使用,就會(huì)很快熟悉的
WdApp.Selection.TypeText (BbDate)
WdApp.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
WdApp.Selection.TypeParagraph
WdApp.Selection.TypeParagraph
’生成列頭
’wdApp.Selection.HomeKey wdLine, wdExtend
’dApp.Selection.Font.Bold = wdToggle
WdApp.ActiveDocument.Tables.Add WdApp.Selection.Range, rowMax, colMax
Dim i As Integer
Do
For colloop = 0 To colMax - 1
WdApp.Selection.Font.Size = 9
If i = 0 Then
’表格中標(biāo)題加粗顯示
WdApp.Selection.Font.Bold = wdToggle’表格標(biāo)題行背景顏色設(shè)置為灰色,灰度為30
With WdApp.Selection.Cells
With .Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorGray30
End With
End With
End If
’最后一行右對齊,其余左對齊
If i > 0 Then
If MyRecord.Fields.Item(colloop).Name = "ZBMC" Or MyRecord.Fields.Item(colloop).Name = "指標(biāo)名稱" Then
WdApp.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
Else
WdApp.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
End If
End If
If i = 0 And (MyRecord.Fields.Item(colloop).Name = "SXH" Or MyRecord.Fields.Item(colloop).Name = "順序號") Then
WdApp.Selection.TypeText ("序號")
Else
WdApp.Selection.TypeText (CStr(MyRecord.Fields.Item(colloop).value))
End If
If (i <> rowMax - 1 Or (i = rowMax - 1 And colloop < colMax - 1)) Then
WdApp.Selection.MoveRight (wdcell)
End If
Next
i = i + 1
MyRecord.MoveNext
Loop Until MyRecord.EOF
WdApp.ActiveDocument.SaveAs DocFileName, 0, False, "", True, "", False, False, False, False, False
WdApp.Quit
SaveAsWord = 1
Exit Function
Err_All:
Set WdApp = Nothing
SaveAsWord = -1
OutMessage = err.Description
Exit Function
End Function
好了,到此為止,我想你們對在VB中利用Word宏命令開發(fā)ASP組件,有了一些了解。只要多使用,就會(huì)很快熟悉的

