ThrottleWorks
Excel Ninja
Hi,
I have a string, this string is partial file name. I am trying to open this file.
But macro is giving bug when am trying.
Folder is present, file name is correct, I checked it manually, do not know where my mistake is.
Can anyone please help me in this. Am getting pop-up as file moved, replaced.
Please note, full file will be something like 'DummyFileName.20200728_12345.CSV'
Files are in CSV format.
20200728 is date part, this will be changed everyday based on some rules.
Hence I am creating date part in Excel and passing DummyFileName.20200728 this as string.
12345 is random number, it can be anything.
So I know fixed parts are, DummyFileName and date part.
That is why am trying to open the file using partial name.
I have a string, this string is partial file name. I am trying to open this file.
But macro is giving bug when am trying.
Folder is present, file name is correct, I checked it manually, do not know where my mistake is.
Can anyone please help me in this. Am getting pop-up as file moved, replaced.
Please note, full file will be something like 'DummyFileName.20200728_12345.CSV'
Files are in CSV format.
20200728 is date part, this will be changed everyday based on some rules.
Hence I am creating date part in Excel and passing DummyFileName.20200728 this as string.
12345 is random number, it can be anything.
So I know fixed parts are, DummyFileName and date part.
That is why am trying to open the file using partial name.
Code:
Public Sub Test
Dim sFile as String
sFile = "I:\Folder1\Folder2\Folder3\DummyFileName.20200728*.csv"
If sFile <> "" Then
MsgBox sFile
Workbooks.Open (sFile )
Else
MsgBox "File not found"
End If
End Sub
Last edited: