Reputation: 277
Hi am very new to VBA and LotusNotes but I'm trying to get all the names of NotesItem within a NotesDocument.
I saw a few examples online but they did not seem to work for me as I am getting an "Object Required" error message. Below are the lines of code that I'm using to try to get all the names of items and concatenate them to a string.
Set domtdoc = domdocs.GetFirstDocument
Dim Item As NotesItem
Dim itemNames As String
itemNames = ""
For Each Item In domtdoc.Items
itemNames = itemNames + (Item.Name) + ", "
Next Item
Can someone please give me some advice on what I may be doing wrong or suggest an alternative way? I also tried with a "Forall" loop but that wouldn't even compile as I seen in this example: http://www-12.lotus.com/ldd/doc/lotusscript/lotusscript.nsf/1efb1287fc7c27388525642e0074f2b6/0f178da5ad5670ea8525642e00765a31?OpenDocument
Ok, I've updated below code using "Forall"
Set domtdoc = domdocs.GetFirstDocument
Dim itemNames As String
Forall i In domtdoc.Items
itemNames = itemNames + i.Name + ", "
End Forall
And I get the following error message
Compile Error: Expected: End of statement
Thanks
Upvotes: 1
Views: 611
Reputation: 277
So what finally worked for me was the following using VBA in Excel which was suggested in the comments. Thank you guys, I will keep in mind the alternative ways to do the same.
Set domtdoc = domdocs.GetFirstDocument
Dim itemNames As String
Dim Item As Integer
For Item = LBound(domtdoc.Items) To UBound(domtdoc.Items)
itemNames = itemNames + domtdoc.Items(Item) + ", "
Next Item
Upvotes: 1
Reputation: 3636
You should use forall, not for each
This should work
Dim doc As NotesDocument
Dim itemNames as String
'...set value of doc...
Forall i In doc.Items
itemNames = itemNames + i.Name + ", "
End Forall
Upvotes: 1