Morning All,
I have the following code in which I am trying to:
-
Determine if a file already exists on a directory
-
If it does create a unique file name for an attachment that I will detach. Note there could be more then one attachment within the named rtf.
When I run the code I am getting an Illegal Function Call error on the: fileExists = Dir$( filePath & uniqueName, 0) line of code.
Here’s the code. Any help would be greatly appreciated.
Dim splitName As Variant
Dim fileExists As String
Dim fileNum As Integer
Dim uniqueName As String
Dim filePath As String
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim Num As Variant
Dim dis As Variant
Dim num1 As Variant
Dim rtitem As Variant
Dim view As NotesView
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
Set doc = collection.GetFirstDocument()
Set view = db.GetView( "Working Parts File" )
Set rtitem = doc.GetFirstItem( "DataSheet" )
If ( rtitem.Type = RICHTEXT ) Then
Num = doc.Num
dis = doc.DisplayAppDate
num1 = doc.Num_2
Forall o In rtitem.EmbeddedObjects
nam = ( o.Name )
End Forall
End If
fileNum = 0
uniqueName = ("C:\Test\" & Num1(0) & "\" & Num(0) & "_"& dis(0) & "\" & nam )
filePath = ("C:\Test\" & Num1(0) & "\" & Num(0) & "_"& dis(0) & "\" & "*.*" )
CheckName:
fileExists = Dir$( filePath & uniqueName, 0)
If Len(fileExists) = 0 Then
Goto ExitFunction
Else
fileNum = fileNum + 1
splitName = Split(uniqueName, ".", 2)
uniqueName = splitName(0) + " (" + Cstr(fileNum) + ")." + splitName(1)
Goto CheckName
End If
ExitFunction:
'GetUniqueFileName = uniqueName
Messagebox uniqueName
TIA,
Teri