I guess I just needed a cup of coffee. Once I took out the While Not statement since it didn’t need it. It works.
Morning,
I have the below script that is not looping as I want it to do, which means of course I wrote it wrong.
What I want it to do: It is to look at the documents in the view “Working Part File” determine if a directory on my C drive is there. If it is then do nothing, otherwise create the folder for a file I will later detach there. Loop to the next document in the view and so on, until all docs are processed and all folders are created that need to be.
Since nothing was working I put a msgbox in the do nothing area.
What it is doing: Goes to the first doc in the view, creates the folder. runs again on the same first doc does not create a folder since it already exists, then repeats itself for the number of docs in the view.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim Num As Variant
Dim stat As Variant
Dim dis As Variant
Set session = New NotesSession
Set db = session.CurrentDatabase
Set view = db.GetView( "Working Part Files" )
Set doc = view.GetFirstDocument
num = doc.Num
stat = doc.Status
dis = doc.DisplayAppDate
Do While Not(doc Is Nothing)
If Dir( "C:\Documents and Settings\terico\My Documents\Test\" & Num(0) & dis(0) & stat(0), 16) > "" Then
Msgbox "Directory already exists" & Num(0) & dis(0) & stat(0)'removed this now it will do nothing if a folder already exists.
Else
While Not(doc Is Nothing)
Mkdir "C:\Documents and Settings\terico\My Documents\Test\" & Num(0) & dis(0) & stat(0)
Wend
End If
Set doc = view.GetNextDocument(doc)
Loop
End Sub
I tried moving my num, stat, and dis to just under the Do While Not. So it looks like below, However this will only process down to when it finds a folder that needs to be created. It will then give me a Path/file access error. I double checked that the folder is not there.
Do While Not(doc Is Nothing)
num = doc.Num
stat = doc.Status
dis = doc.DisplayAppDate
If Dir( "C:\Documents and Settings\terico\My Documents\Test\" & Num(0) & dis(0) & stat(0), 16) > "" Then
Msgbox "Directory already exists" & Num(0) & dis(0) & stat(0)'removed this now it will do nothing if a folder already exists.
Else
While Not(doc Is Nothing)
Mkdir "C:\Documents and Settings\terico\My Documents\Test\" & Num(0) & dis(0) & stat(0)
Wend
End If
Set doc = view.GetNextDocument(doc)
Loop
So, where am I going wrong?
Thanks in Advance for any help.
Teri