我想知道 Excel 用vba 如何创建目录选择按钮。 就是单击按钮找到目标文件的路径

如题所述

下面是控件CommandButton1,单击时执行的代码:
Private Sub CommandButton1_Click()
Application.Calculation = xlCalculationManual '手动重算
Dim theSh As Object
Dim theFolder As Object
Set theSh = CreateObject("shell.application")
Set theFolder = theSh.BrowseForFolder(0, "", 0, "")
If Not theFolder Is Nothing Then
Range("C3") = theFolder.Items.Item.Path '在当前表A1单元格录入文件夹路径
End If
Application.Calculation = xlCalculationAutomatic '自动重算
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-01-18
没明白,你可以说具体一点。

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网