Open windows folder and select a file

Davide78

New Member
Joined
Apr 20, 2023
Messages
17
Office Version
  1. 2019
Platform
  1. Windows
Hello, I'm Davide and it's the first time I've tried to register on a non-Italian excel forum, I saw that Mr Excel has this section to be able to write in his own language and I tried to ask a question in Italian, but having received no response I try to rewrite it here.
I state that I am not able to write code in VBA even if I managed to do something through explanations, I know how to use macros but I don't understand them overall, having said that, the question I ask you concerns a macro that I have found and that I use regularly.
The macro in question allows me, given a file name with extension of any type and its path, to open the folder where it resides.
I would like to improve it to have the ability to have the file selected once the folder is opened.

Via download link I share:
1) TEST.zip file which, once unpacked, creates a folder containing files, to run the test this folder must be placed in "C"
2) file with file list with path.zip that once unpacked contains the excel file that lists the files in the Prova folder and their path in the folder C:\PROVA
On this file there is the macro Sub ApriCartella(), positioning on a cell compiled and running the macro opens the folder C:\PROVA (in the example all the files are in C:\PROVA, but I use this system in a very more structured)

I would like the file of the line you are on when you run the macro to be selected when you open the folder of its path

Thanks in advance for any help and I apologize if I used sharing methods that were not suitable for the guidelines, but I didn't know how to provide you with this practical example, if so, let me know how to update the post
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hi Davide,

welcome to the forum. I have looked at your workbook and macro.

As you say it works fine, opening filemanager with the folder containing the selected file.

However I don't know of a method to then scroll down in filemanager (FM) to the selected file. This is because FM does not return any feedback to VBA. I could fill out the 'find' box in FM and do a search, but then it will only show this one file, not the whole folder anymore.

Why do you want to have the file selected in FM?
  • If you want to open the selected file without the user needing to select it, then that is very easy to achieve.
  • But if you want just to select the file and wait for user input, then I don't know how to do it.

If you want to open the selected file instead of opening the folder in FM then modify your macro as follows:
VBA Code:
Sub ApriCartella()
    Dim iCart As String
    Dim Domanda As VbMsgBoxResult
   
   
    iCart = Range("E" & (ActiveCell.Row)).Value
    If Dir(iCart, vbDirectory) = "" Then
        Domanda = MsgBox("La cartella non esiste, la vuoi creare", vbQuestion + vbYesNo, "ATTENZIONE")
        If Domanda = vbYes Then
            MkDir iCart
        Else
            Exit Sub
        End If
    End If
    ActiveWorkbook.FollowHyperlink Address:=iCart & "\" & ActiveCell, NewWindow:=True

End Sub
 
Upvote 0
Thanks for the help, I got help here in the meantime:
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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