需要有关 vba 代码的帮助。请看下面的代码。
我想要 QA\QA Schedule 视图中的所有文档,它们介于 (1sep2013 - 30sep2013) 之间。这里不是文档创建日期,而是从视图列中获取的日期,以便我可以在 Excel 中提取数据
'下面是我构建的代码,它正在搜索所有文档并获取需要大量时间的数据。如果可以在日期上添加过滤器,我们可以更快一点,但我不知道 FT 搜索语法。如何在视图列上使用它。请帮助解决这个问题,这真的很紧急。
Dim nSess As Object 'NotesSession
Dim sPwd As String
Dim strCnxn As String
Dim strSQL As String
Dim db As Object
Dim iviews As Object
Dim IView As Object
Set nSess = CreateObject("Lotus.NotesSession") 'New:{29131539-2EED-1069-BF5D- 00DD011186B7}
myUsername = ****
myPassword = ****
DSN1 = ("Driver={Lotus NotesSQL Driver (*.nsf)};Server=;Database=;Uid=" & myUsername & ";Pwd=" & myPassword & ";")
Call nSess.Initialize(sPwd)
Set db = nSess.GetDatabase("", "")
Set iviews = db.GetView("QA\QA Schedule")
iviews.AutoUpdate = False
Set IView = iviews.AllEntries
Set viewparentEntry = IView.Parent
Set viewEntry = viewparentEntry.GetFirstDocument
For i = 1 To IView.Count
Colval = viewEntry.ColumnValues()
For j = 0 To 20
If Colval(0) <> "2013 9" Then
Exit For
ElseIf Colval(18) >= "" Or Colval(18) <= "" Then
Exit For
ElseIf Colval(18) >= "09/01/2013" Or Colval(18) <= "09/30/2013" Then
Sheets("Sheet2").Cells(RowCount, colcount).Value = Colval(j)
colcount = colcount + 1
Else
Exit For
End If
Next
j = 0
colcount = 1
RowCount = RowCount + 1
Set viewEntry = viewparentEntry.GetNextDocument(viewEntry)
Next