我目前正在编写这个应用程序来打印和创建一个新的 Word 文档的报告。然而,我遇到了一个绊脚石。当我将数据写入这个新的 Microsoft word doc 以检查它是否是一个新页面时,他们有什么办法吗?例如,报告占用 10 页,他们是一种检查应用程序何时开始在新页面上写入的方法吗?
代码:
Dim objWord
As Word.Application
Dim objDoc As Word.Document
Dim objTable As Word.Table
Dim r As Integer, c As Integer
Dim pages1 As Pages
Dim pagecountbefore As Integer
objWord = CreateObject("Word.Application")
objWord.Visible = True
objDoc = objWord.Documents.Add
pagecountbefore = pages1.Count
objTable = objDoc.Tables.Add(objDoc.Bookmarks.Item("\endofdoc").Range, 3, 5)
objTable.Range.ParagraphFormat.SpaceAfter = 6
For r = 1 To 1000
For c = 1 To 5
If r = 1 Then
Select Case c
Case "1"
objTable.Cell(r, c).Range.Text = "PCI DSS Requirements "
Case "2"
objTable.Cell(r, c).Range.Text = "Testing Procedures "
Case "3"
objTable.Cell(r, c).Range.Text = "In Place"
Case "4"
objTable.Cell(r, c).Range.Text = "Not in Place"
Case "5"
objTable.Cell(r, c).Range.Text = "Target Date/ Comments"
End Select
Else
If pagecountbefore<pages1.Count Then
pagecountbefore = pages1.Count
Select Case c
Case "1"
objTable.Cell(r, c).Range.Text = "PCI DSS Requirements "
Case "2"
objTable.Cell(r, c).Range.Text = "Testing Procedures "
Case "3"
objTable.Cell(r, c).Range.Text = "In Place"
Case "4"
objTable.Cell(r, c).Range.Text = "Not in Place"
Case "5"
objTable.Cell(r, c).Range.Text = "Target Date/Comments"
End Select
Else
'print resultrs from database
End If
End If
Next
Next