使用 VB6 的 Microsoft Word 报告问题
Microsoft Word report issue using VB6
textPositionOFf 我正在用 VB6 构建一份报告,以便在 Microsoft Word 中打印。我在处理现有报告时发现了一些本不应该发生的问题。我基本上是在处理已创建的报告,并且正在制作自己的报告。我有一个创建 header 的快速函数,我在其中传递参数,主要是行号和标题文本。
对于应用 Borders 的三行代码,我收到一条错误消息“5941 - collection 的请求成员不存在”我正在查看另一份报告,它看起来完全一样就像我的一样,我收到了这个错误。有谁知道可能是什么问题?
Private Sub TableStyle_001_HeaderLine(row As Integer, Col1Txt As String)
On Error GoTo error_handler:
w_Doc.Tables.Add w_Rng, 1, 1
w_Wrd.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
With w_Wrd.Selection.Tables(w_DocTblIdx).Rows(row)
With .Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorGray15
End With
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone 'error here
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone 'here
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone 'and here
.Borders.Shadow = False
'WRITE THE DATA
.Cells(1).Select
w_Wrd.Selection.Font.Bold = True
w_Wrd.Selection.TypeText Col1Txt
End With
如果 table 单元格中没有对话线,或者代码针对的是不支持对角线的早期版本的 Word,则这些代码行是不必要的。如果此报告未被任何可能向 table 单元格添加对角线的人编辑,则注释掉这些线并注明它们在不同的 "incarnation" 报告代码中但不是必需的对于此代码正在处理的模板。
textPositionOFf 我正在用 VB6 构建一份报告,以便在 Microsoft Word 中打印。我在处理现有报告时发现了一些本不应该发生的问题。我基本上是在处理已创建的报告,并且正在制作自己的报告。我有一个创建 header 的快速函数,我在其中传递参数,主要是行号和标题文本。
对于应用 Borders 的三行代码,我收到一条错误消息“5941 - collection 的请求成员不存在”我正在查看另一份报告,它看起来完全一样就像我的一样,我收到了这个错误。有谁知道可能是什么问题?
Private Sub TableStyle_001_HeaderLine(row As Integer, Col1Txt As String)
On Error GoTo error_handler:
w_Doc.Tables.Add w_Rng, 1, 1
w_Wrd.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
With w_Wrd.Selection.Tables(w_DocTblIdx).Rows(row)
With .Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = wdColorGray15
End With
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = wdColorAutomatic
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone 'error here
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone 'here
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone 'and here
.Borders.Shadow = False
'WRITE THE DATA
.Cells(1).Select
w_Wrd.Selection.Font.Bold = True
w_Wrd.Selection.TypeText Col1Txt
End With
如果 table 单元格中没有对话线,或者代码针对的是不支持对角线的早期版本的 Word,则这些代码行是不必要的。如果此报告未被任何可能向 table 单元格添加对角线的人编辑,则注释掉这些线并注明它们在不同的 "incarnation" 报告代码中但不是必需的对于此代码正在处理的模板。