I am trying to use the following syntax to open the active workbook Location and select the file at the same time:
Shell "C:\Windows\explorer.exe /select," & location, vbMaximizedFocus
Where location is the path for the active workbook
It works perfectly except when the folder that I am trying to open contains a comma on its name.
For instance: C:\Users\q1Bossymess\CpSolution\CpSolution - Fairgrounds\06-2025 FY\Reports, Clinical\08.25.24 AaSS.xlsx
If I copy the whole path and paste it in the address bar of Windows Explorer, it opens the folder without any problem
The problem starts when I try to use the Shell Statement.
If I rename the target folder with the comma from "Reports, Clinical" to something else, everything works perfectly.
I can't change the name of the folders because I am building an Add-in that is going to be used for different people in different computers and it needs to work every single time on all circumstances.
Thanks.
I just found what the problem is by changing the name of the Folder to detect the problem. It works perfect when the folder name has a "&" or "-" but does not works with commas in the folder name.
My expectation is to be able to open any folder and highlight the active workbook on Windows Explorer, which works great except the comma issue.
Quote the path:
Shell "C:\Windows\explorer.exe /select,""" & location & """", vbMaximizedFocus