Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Modified File Organization Roadsignologist Excel Discussion (Misc queries) 3 December 18th 08 04:34 PM
date file modified Matthew Excel Discussion (Misc queries) 2 October 11th 06 06:52 PM
Get the date a file was modified JustinP Excel Programming 2 September 5th 06 04:54 AM
insert the date the file was last modified Hoff Excel Discussion (Misc queries) 8 November 21st 05 01:31 PM
Detect if a file is in use or being modified shawb[_2_] Excel Programming 3 June 28th 05 01:04 PM


All times are GMT +1. The time now is 04:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"