DonAndress
Active Member
- Joined
- Sep 25, 2011
- Messages
- 362
- Office Version
- 2019
- 2016
- Platform
- Windows
Hello.
I have a code like below:
And both wbName "MsgBox" print correct paths (asterisks are present).
Then when it comes to testing whether files actually exist I get a run-time error 1004 for the second one (appro).
But in the error message box excel prints the exact name of the file (no asterisk anymore, it prints the full name with the rest of the name in the file) and while I have not defined it as a constant for me it means it found the file in the specified folder.
I double checked the paths, both files exist and I have only file for each name so no confusion with the "*" is possible.
Plus I am sure the same code worked yesterday when I wrote it
Can anyone assist on that matter?
How to fix that?
I have a code like below:
Code:
'check first file
'
MyPath_contract = "G:\booking\"
MyClient_contract = "BLK BGF " & contract_name & " Deal Report"
wbName_contract = MyPath_contract & MyClient_contract & "*.csv"
MsgBox (wbName_contract)
If Dir(wbName_contract) = "" Then
MsgBox ("No 'contract notes' file for " & contract_name & " " & fund_name & " fund." & vbNewLine & "Please save.")
Exit Sub
End If
'check second file
'
MyPath_appro = "G:\booking\"
MyClient_appro = "BLK_GIS_" & appro_name & "_Appro_Expro"
wbName_appro = MyPath_appro & MyClient_appro & "*.csv"
MsgBox (wbName_appro)
If Dir(wbName_appro) = "" Then
MsgBox ("No 'appro expro' file for " & appro_name & " " & fund_name & " fund." & vbNewLine & "Please save.")
Exit Sub
End If
And both wbName "MsgBox" print correct paths (asterisks are present).
Then when it comes to testing whether files actually exist I get a run-time error 1004 for the second one (appro).
But in the error message box excel prints the exact name of the file (no asterisk anymore, it prints the full name with the rest of the name in the file) and while I have not defined it as a constant for me it means it found the file in the specified folder.
I double checked the paths, both files exist and I have only file for each name so no confusion with the "*" is possible.
Plus I am sure the same code worked yesterday when I wrote it
Can anyone assist on that matter?
How to fix that?