• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Filename checking before open

Villalobos

Active Member
Hello,

I would like to ask regarding the file naming.
Is it possible if I would like that the code check name of file before the opening and if it is doesn't match with the pre-definied name then the file stay in closed?

Thanks in advance the response!
 
Hi,

I have uploaded an empty sample file.
How do you mean "Which type of file & where it's located."? If for this then... the type of file is .xlsm, the location should not to matter just the name.
 

Attachments

Ha ha ha!!
What the file you have uploaded ???
You must to be awarded for the same.

However try the below code in "Thisworkbook" & must create the backup of the file before you try.

Code:
Option Explicit
Private Sub Workbook_Open()
Dim file As String
file = "C:\BAC\GGG\DDE\New\xyz.xlsm"  ' Must change before try
If Dir(file) = "" Then ThisWorkbook.Close False
End Sub
 
Back
Top