ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to "match" partial file name (https://www.excelbanter.com/excel-programming/362723-how-match-partial-file-name.html)

BEEJAY

How to "match" partial file name
 
Greetings:
When file is open and special menu item selected, the first thing that
needs to be done is determine if the file name start with "EM_".
If if does, then call up message, "not allowed" and exit
if is doesn't, then continue with process.
Please see my efforts, below

Sub CheckFileName()

' if File Name starts with 'EM_', then process is not allowed.
' When click on OK, exit macro project
' If does NOT start with 'EM_', then Proceed
' Call EMailAnswerC1A

Dim FName As String

If FName = "EM_*" Then
Call NotAllowed
Else: Call EMailAnswerC1A
End If

How (or what) can I use as a wild card, to make this work.
(there is no fixed file name length)


Ardus Petus

How to "match" partial file name
 
if left(FName,3) = "EM_" then
call NotAllowed
--
AP

"BEEJAY" a écrit dans le message de news:
...
Greetings:
When file is open and special menu item selected, the first thing that
needs to be done is determine if the file name start with "EM_".
If if does, then call up message, "not allowed" and exit
if is doesn't, then continue with process.
Please see my efforts, below

Sub CheckFileName()

' if File Name starts with 'EM_', then process is not allowed.
' When click on OK, exit macro project
' If does NOT start with 'EM_', then Proceed
' Call EMailAnswerC1A

Dim FName As String

If FName = "EM_*" Then
Call NotAllowed
Else: Call EMailAnswerC1A
End If

How (or what) can I use as a wild card, to make this work.
(there is no fixed file name length)




BEEJAY

How to "match" partial file name
 
Ardus:
I made the adjustments as shown, but I cannot get it to work.
Every time it goes to the "else" statement, even though the active file
does start with "EM_".
What am I overlooking?


"Ardus Petus" wrote:

if left(FName,3) = "EM_" then
call NotAllowed
--
AP

"BEEJAY" a écrit dans le message de news:
...
Greetings:
When file is open and special menu item selected, the first thing that
needs to be done is determine if the file name start with "EM_".
If if does, then call up message, "not allowed" and exit
if is doesn't, then continue with process.
Please see my efforts, below

Sub CheckFileName()

' if File Name starts with 'EM_', then process is not allowed.
' When click on OK, exit macro project
' If does NOT start with 'EM_', then Proceed
' Call EMailAnswerC1A

Dim FName As String

If FName = "EM_*" Then
Call NotAllowed
Else: Call EMailAnswerC1A
End If

How (or what) can I use as a wild card, to make this work.
(there is no fixed file name length)





BEEJAY

How to "match" partial file name
 
Ardus:
I'll repost, since I have some related issues.

"BEEJAY" wrote:

Ardus:
I made the adjustments as shown, but I cannot get it to work.
Every time it goes to the "else" statement, even though the active file
does start with "EM_".
What am I overlooking?


"Ardus Petus" wrote:

if left(FName,3) = "EM_" then
call NotAllowed
--
AP

"BEEJAY" a écrit dans le message de news:
...
Greetings:
When file is open and special menu item selected, the first thing that
needs to be done is determine if the file name start with "EM_".
If if does, then call up message, "not allowed" and exit
if is doesn't, then continue with process.
Please see my efforts, below

Sub CheckFileName()

' if File Name starts with 'EM_', then process is not allowed.
' When click on OK, exit macro project
' If does NOT start with 'EM_', then Proceed
' Call EMailAnswerC1A

Dim FName As String

If FName = "EM_*" Then
Call NotAllowed
Else: Call EMailAnswerC1A
End If

How (or what) can I use as a wild card, to make this work.
(there is no fixed file name length)






All times are GMT +1. The time now is 02:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com