View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 380
Default Search for active file name (modified), then....

Sub CheckFileName()
' Check if the following exists:
' C:\Contracts EMailed\'filename'_EM.xls
' IF it exists, then Process is not allowed
' NotAllowed Message pops up, Click OK, and project Exits
' If it does NOT exist, then Continue

Dim FName As String
FName = ActiveWorkbook.Name
Dim NewName As String
NewName = FName + "_EM"

' The following line comes up with Compile Error - Syntax error

If Dir("C:\Contracts EMailed\" & NewName) = "" Then

Call NotAllowed

Else: Exit Sub
End If
End Sub

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"BEEJAY" wrote in message
...
When a file has been E-Mailed with my code, it is saved as
C:\Contracts EMailed\'Current file name' + _EM.
IF one tries to resave the original file, this code is to check
if it has been saved before.
If YES, then, exit, if NO, continue.

Sub CheckFileName()
' Check if the following exists:
' C:\Contracts EMailed\'filename'_EM.xls
' IF it exists, then Process is not allowed
' NotAllowed Message pops up, Click OK, and project Exits
' If it does NOT exist, then Continue

Dim FName As String
FName = ActiveWorkbook.Name
Dim NewName As String
NewName = FName + "_EM"

' The following line comes up with Compile Error - Syntax error

If "C:\Contracts EMailed\NewName.Exists = True Then

Call NotAllowed

Else: Exit Sub
End If
End Sub