VBA File Path question

mayoung

Board Regular
Joined
Mar 26, 2014
Messages
172
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I am creating a custom addin that takes reports that have been down loaded out of our business System and then through VBA uploads the data into excel.
The downloaded report out our business system goes into a download file on our computer.,
The file path would be: C:\User\ myoung\dowloads. The myoung would be the persons computer this particular file 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 file path have to be set up? Or is there a work around for this?
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,833
Office Version
  1. 365
Platform
  1. Windows
Another option
VBA Code:
MyPath=environ("Userprofile")&"\Downloads\"
 

mayoung

Board Regular
Joined
Mar 26, 2014
Messages
172
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Another option
VBA Code:
MyPath=environ("Userprofile")&"\Downloads\"

How Do I get the Path & MyPath Code to open the DataminerFile.xml?

The only code I can get to work is the first one Workbooks.Open

VBA Code:
Workbooks.Open ("C:\Users\myoung\OneDrive - Bobs Enterprises Inc\Downloads\DataminerFile.xml")
 
Path = "C:\Users\" & Environ("username") & "\OneDrive - Bobs Enterprises Inc\Downloads\DataminerFile.xml"
 
MyPath = Environ("userProfile") & "\OneDrive - Bobs Enterprises Inc\Downloads\Dataminer.xml"
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,833
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

I have never used OneDrive or xml files, but you could try
VBA Code:
MyPath = Environ("userProfile") & "\OneDrive - Bobs Enterprises Inc\Downloads\Dataminer.xml"
Workbooks.Open MyPath
 

mayoung

Board Regular
Joined
Mar 26, 2014
Messages
172
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I have never used OneDrive or xml files, but you could try
VBA Code:
MyPath = Environ("userProfile") & "\OneDrive - Bobs Enterprises Inc\Downloads\Dataminer.xml"
Workbooks.Open MyPath

That worked for Both lines of code. Thank You
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,833
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Glad we could help & thanks for the feedback.
 

mayoung

Board Regular
Joined
Mar 26, 2014
Messages
172
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Glad we could help & thanks for the feedback.


What if this was a folder you wanted to open instead of a workbook? How would you go about that?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,833
Office Version
  1. 365
Platform
  1. Windows
That's a totally different question, so needs a new thread. Thanks.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,363
Messages
5,595,705
Members
414,013
Latest member
tnobbs

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
Top