VBA to open explorer and select, not open, a selected file name

Dwaashaas

New Member
Joined
Apr 24, 2014
Messages
2
Hi there,

I want a macro to open windows explorer and just select a file but don’t want it to open the file.
I’ve got a list of document names in excel split into some variables.
I also included some hyperlinks in it, so you can directly open the selected file.
But now I want a macro that selects the corresponding file in explorer and just selects it.
All files are in a predefined location, but all filenames are different, off course.
Example;
D:\username\Documents\workplans\document.001.1.xls
D:\username\Documents\workplans\document.002.2.xls
D:\username\Documents\workplans\document.003.3.xls

I want to select the corresponding file name in excel, and start the macro to select it in explorer.
So for example I select cell D3 and start the macro so it opens explorer and go’s to the following address and selects the file; D:\username\Documents\workplans\document.002.2.xls

A
B
C
D
E
1
var 1
var 2
var 3
doc. Name
Hyperlink
2
document
1
1
document.001.1.xls
document.001.1
3
document
2
2
document.002.2.xls
document.002.2
4
document
3
3
document.003.3.xls
document.003.3

<tbody>
</tbody>


If I use the following code directly to the link it works like how I want it to be, but the file name is variable.

Sub open_explorer()
Shell "C:\Windows\explorer.exe /select,D:\username\Documents\workplans\document.002.2.xls", vbMaximizedFocus
End Sub

I adjusted the code, but it won’t work. I think the problem is in the (& range (activeCell.select)).
How do I get this to work?

Sub open_explorer()
Shell "C:\Windows\explorer.exe /select, D:\username\Documents\workplans\ &Range ActiveCell.Select", vbMaximizedFocus
End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,215,945
Messages
6,127,851
Members
449,411
Latest member
adunn_23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top