需要有关vba代码的帮助。请看下面的代码。
我想要查看QA \ QA时间表中的所有文件(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
答案 0 :(得分:1)
有几个选择:
您可以复制此视图或将此视图更改为仅在特定日期范围之间显示文档(如果适用)。
您可以在数据库视图上调用FTSearch方法。 Some info on syntax for full text searches is here
这是一个示例,它可以获取从视图上的全文搜索返回的文档集合:
Dim db As Object
Dim iviews As Object
Dim IView As Object
Dim doc as NotesDocument
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
iviews.FTSearch("[SomeDate] >= 9/1/2013 And [SomeDate] <= 9/30/2013")
Set doc = iviews.GetFirstDocument
While Not (doc Is Nothing)
// Do something here for each document
Set doc = iviews.GetNextDocument(doc)
Wend