繁体   English   中英

使用VBA从Excel工作表中的列表中打开文件夹

[英]Open folder from list in Excel sheet using VBA

此代码用于打开特定的文件夹。

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

我需要打开一个保存在Excel工作表中的文件夹(如下图所示)。 我需要在Excel中读取路径并打开文件夹。

假设您在A到C的前三列中都有表格。您可以在单元格E1中写入序列号并运行宏。 例如,如果您在单元格E1中输入3并单击按钮,则来自Edres的文件夹将打开。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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