(Solved) – How to search for a specific number in a string?

  • by

So I have a code that prompts the user to find a specific file on their computer. the files are always named like this “Daily Operations Report – DAY MONTH YEAR“.
I need to make sure that the file the user chose has the same date as today. I know how to compare the 2 dates and find out if they are equal or not. However, I don’t know how to let excel find a number in a string.

'Previous code not relevant to the question

Dim strFilePath, fName As String
Dim wdDoc As Object

strFilePath = Application.GetOpenFilename
    If strFilePath = "False" Then End  'Pressed cancel

fName = strFilePath

Set wdDoc = GetObject(fName)

After executing the above code, I can find the name of the file in (wdDoc), for example:

 MsgBox wdDoc

I get the following result :

Daily Operations Report – 21st December 2019

How can I compare the file to today’s date? I believe comparing the number of days would be easier and faster than comparing both the days, months and years for the two dates?

Sorry if I didn’t make sense I just keep thinking about this step for a while now.

Any help is appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *