Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Search for active file name (modified), then....
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Search for active file name (modified), then....
Bob:
Thanks for the prompt response. I am having some difficulty with the process. It exits when the file exists - That is Correct It also exits when the file does NOT exist - Thats when it SHOULD go thru the complete code. In case my eye-sight was bad, I also tried a cut and paste from your message. Same result. In case it may help, I show below the message that (should only) come up when the file does exist. Sub NotAllowed() Dim Msg As String, Title As String Dim Config As Integer, ans As Integer Msg = " This process may NOT be used on an " Msg = Msg & vbNewLine & vbNewLine Msg = Msg & " 'E-Mail Safe' File" Msg = Msg & vbNewLine & vbNewLine Msg = Msg & " Please click on OK" Msg = Msg & vbNewLine & vbNewLine Msg = Msg & " You will be exited from this procedure" Msg = Msg & vbNewLine & vbNewLine Config = vbOKOnly = vbExclamation ans = MsgBox(Msg, Config, Title) If ans = vbOK Then ActiveWorkbook.Close: End End Sub "Bob Phillips" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Date Modified File Organization | Excel Discussion (Misc queries) | |||
date file modified | Excel Discussion (Misc queries) | |||
Get the date a file was modified | Excel Programming | |||
insert the date the file was last modified | Excel Discussion (Misc queries) | |||
Detect if a file is in use or being modified | Excel Programming |