I have a few thousand project folders, which then has then several documents inside them. All these documents should have title, date, Issue and Author in clear text in the document. However unfortunately some does document does not have this.
So what I am doing is that my loop does is that it loops through all documents, figure out whats missing as well as grabbing author from file-properties.
Then I want to print out for every user:
XX user you need to fix this in :
document XXX: title, date
Document XXX: author,issue
........
So what I am trying to do is to populate the outer dictionary with user as key and the inner dictionary with document name(Is there any character limitation in Dictionary Keys?, full filepath should be ok as key)
However for some reason this does not work, it finds all user, but inner nested dictionary is empty!
So whenever i find a missing thing(title,author,issue,date) in a document I call this procedure:
Call addItemToDict(emailDict, userName, "Description of the error", doc)
then that procedure should add it to the nested dictionary:
Public Sub addItemToDict(ByRef emailDict As Object, user As String, text As String, ByRef doc As Document)
Dim temp As Object
Set temp = CreateObject("Scripting.Dictionary")
'check if user exist
If emailDict.Exists(user) Then
Set temp = emailDict(user)
'check if document exist
If temp.Exists(doc.fullName) Then
emailDict(user)(doc.fullName) = emailDict(user)(doc.fullName) & vbNewLine & text
Else
temp.Add doc.fullName, "Dokumentet " & embedLink(doc.fullName, doc.name) & " har mangler: " & vbNewLine & text
Set emailDict(user) = temp
End If
Else
temp.Add doc.fullName, "Dokumentet " & embedLink(doc.fullName, doc.name) & " har mangler: " & vbNewLine & text
emailDict.Add user, temp
End If
End Sub
and when I am done looping i try to print out the result(or email it)
' print all mistakes ...
Dim key, key2 As Variant
For Each key In emailDict.keys
'we need to double check that the user really exist..
rowMy = CPearson.findRownumber(key, Settings.userArray, 0)
If rowMy <> -1 Then
For Each key2 In emailDict(key).keys
' all mistakes....
outputString = outputString & vbNewLine & emailDict(key)(key2)
Next key2
emailAddress = Settings.userArray(rowMy, 4)
Call email.send_Email(emailAddress, "Email Subject....", _
"Some nice intro text.... " & vbNewLine & outputString)
End If
Debug.Print key, emailDict(key)
Next key