macro to check if folder exist and if not create it

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi everyone,
I need a macro that can create a folder in the "My Documents" folder of the computer its being run on without knowing the path.
the excel document the macro is being run on will be held in sharepoint and opened so i'm a bit confused as to how to refer to the computer its being run on?
please help if you can
Thanks
Tony
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How are you opening the file--in the browser version of Excel, or on an installed desktop version? The two versions use two different macro languages.

In VBA:

VBA Code:
On Error Resume Next
MkDir Environ("USERPROFILE") & "\My Documents"
On Error GoTo 0
 
Upvote 0
Solution
So VBA is the answer. See above code. If you have no VBA experience I will have to give more detailed instructions, and also ask you what action you want to trigger running the macro.
 
Upvote 0

Forum statistics

Threads
1,214,988
Messages
6,122,620
Members
449,092
Latest member
amyap

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