Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
413 views
in Technique[技术] by (71.8m points)

excel - 如何在不通过VBA使用用户名的情况下打开Windows文件夹?(How to open windows folder without using username via vba?)

I am trying to open a windows folder (Downloads folder) via a commandbutton in a userform in Excel.

(我正在尝试通过Excel用户窗体中的命令按钮打开Windows文件夹(下载文件夹)。)

However I want to use a generic folder path to access the downloads folder so whoever has this excel file can open their downloads folder.

(但是,我想使用通用文件夹路径来访问下载文件夹,以便拥有此excel文件的任何人都可以打开其下载文件夹。)

I got this code from the internet but it doesn't work, it only opens the document folder which I believe is the default folder.

(我从互联网上获取了此代码,但是它不起作用,它只能打开文档文件夹,我相信这是默认文件夹。)

    Private Sub CommandButton1_Click()
            Shell "explorer.exe" & " " & "C:Users\%USERNAME%Downloads", vbNormalFocus
    End Sub

How can I achieve that?

(我该如何实现?)

  ask by Frank translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...