VBA to Open Folder

mayoung

Active Member
Joined
Mar 26, 2014
Messages
257
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I am creating a custom addin how would you open just a folder

The folder path would be: C:\User\ myoung\dowloads. The myoung would be the persons computer this particular folder path is for. But several people want this addin in on there computer in excel. My question is, is there away to make a path so the VBA gets to the download folder of the persons which the addin is installed on or does each different folder path have to be set up? Or is there a work around for this?
I have the below three examples for opening a file, but how can this code be changed to open a folder?

VBA Code:
Workbooks.Open ("C:\Users\myoung\OneDrive - Bobcat Enterprises Inc\Downloads\DataminerFile.xml")

Path = "C:\Users\" & Environ("username") & "\OneDrive - Bobcat Enterprises Inc\Downloads\DataminerFile.xml"

MyPath = Environ("userProfile") & "\OneDrive - Bobcat Enterprises Inc\Downloads\Dataminer.xml"
 
Last edited:
How about
VBA Code:
Sub mayoung()
   Dim Fname As String
   
   With Application.FileDialog(3)
      .InitialFileName = Environ("Userprofile") & "\Downloads\"
      .AllowMultiSelect = False
      If .Show Then Fname = .SelectedItems(1)
   End With
   ActiveWorkbook.FollowHyperlink Fname
End Sub

Code worked well Thank You
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,104
Members
448,548
Latest member
harryls

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