Hi all can someone help me with this one?
I have written the following code but I can not get it to work.
fname = pname & "_" & ia & "_" & onmae & ".doc"
Set fs = application.FileSearch
With fs
.LookIn = application.CurrentProject.Path & "\database files\letter"
.FileName = fname
While Len(.FileName) > 0
If Len(.FileName) > 0 Then
ia = ia + 1
fname = pname & "_" & ia & "_" & onmae & ".doc"
.LookIn = application.CurrentProject.Path & "\database files\letters"
.FileName = fname
Else
'filename exits we need to create another filename
strtest = MsgBox("We are about to create document " & fname & " is this ok?", vbYesNo, "Warning")
If strtest = vbNo Then
Exit Sub
End If
End If
wend
End With
This just loops.
What I want to do is look in a folder. If the exists then create another file which is incremented by the counter ia.
Any ideas as to how this should be done
I have written the following code but I can not get it to work.
fname = pname & "_" & ia & "_" & onmae & ".doc"
Set fs = application.FileSearch
With fs
.LookIn = application.CurrentProject.Path & "\database files\letter"
.FileName = fname
While Len(.FileName) > 0
If Len(.FileName) > 0 Then
ia = ia + 1
fname = pname & "_" & ia & "_" & onmae & ".doc"
.LookIn = application.CurrentProject.Path & "\database files\letters"
.FileName = fname
Else
'filename exits we need to create another filename
strtest = MsgBox("We are about to create document " & fname & " is this ok?", vbYesNo, "Warning")
If strtest = vbNo Then
Exit Sub
End If
End If
wend
End With
This just loops.
What I want to do is look in a folder. If the exists then create another file which is incremented by the counter ia.
Any ideas as to how this should be done