Macro to check if folder/subfolder exist for any user if not create them and save file

1nk3d

Board Regular
Joined
May 31, 2016
Messages
51
Hello all.

I am looking for a 3 in one here. I have a macro that will save a file automatically when ran. However, I am looking to use a new macro for a workbook.

I do not have any code right now, as everything I found has not worked.

What I want to do is check if a folder/subfolder exist on a users desktop, however everyone who will have access, has their own user.

Ideally it would be saved on the desktop under Reports/Feb (I can change the macro each Month as needed.

If that path does not exist, I want the macro to create it

The last part would be saving it as todays date & report.
 
I have an updated question, some users on excel 2010 are getting a compile error, and when I remove the password, VBA highlights the Date, any ideas?

Try this version of the Test macro:

Code:
Public Sub Test()

    Dim desktopSubfolder As String
    Dim fullFileName As String
    
    desktopSubfolder = Create_Desktop_Subfolder("\Reports\" & Format(Date, "Mmm"))
    fullFileName = desktopSubfolder & "\" & Format(Date, "yyyy-mm-dd") & " Report" & Mid(ThisWorkbook.Name, InStrRev(ThisWorkbook.Name, "."))
    ThisWorkbook.SaveCopyAs fullFileName
    MsgBox "Saved " & fullFileName
    
End Sub
Another change is that the macro now saves the file in the subfolder for the current month, so there is no need to edit the code from month to month.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
To fix that error, change Date to VBA.Date. You might need to add the "VBA." prefix for the other VBA intrinsic functions - Format, Mid and InStrRev.

If no joy, check for MISSING references in Tools -> References.
 
Upvote 0
Is there a way I can test this? As the original code worked fine but user with excel 2010 we’re having issues
 
Upvote 0
Seems to work so far, I found an old machine running 2010 so I’m using that to verify the functionality, appears to be working. Will keep you posted, thank you
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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