简体   繁体   中英

Open folder from list in Excel sheet using VBA

This code is used to open a specific folder.

Dim strFolderPath As String 
strFolderPath = “C:\temp\” 
ThisWorkbook.FollowHyperlink (strFolderPath)

I need to open a folder saved in an Excel sheet (like in the image below). I need to read the path in Excel and to open the folder.

Let's say you have your table in the first three columns from A to C. You can write your serial number in cell E1 and run macro. For example, if you enter 3 in cell E1 and click the button, the folder from Edres will be open.

Dim strFolderPath As String
Dim NrRow As Long
NrRow = Cells(1, 5)
strFolderPath = Cells(NrRow + 1, 3).Value
ThisWorkbook.FollowHyperlink (strFolderPath)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM