Can anyone advise on macros for pc rather than excel

tweacle

Rules violation
Joined
Nov 8, 2005
Messages
382
Ladies and Gents

First of all apologies if in wrong forum but donno if anyone can help.


I know you can do macros for Excel and Word but can you do macros that run on the PC?

I’m trying to get the PC to open “S:\CCTV Downloads\Downloads” and then sort the subfolders into date order. After that I want it to look for subfolders that had date created over 30 days ago and if so I need them deleted.

Is that possible?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Sorting is irrelevant.

If you have folders that are over 30 days ago the folder simply needs deleting, sorting is not required.
You only need sorting if you want to display the remaining folders once the other folders have been deleted.
Sorting folders you are about to delete is inefficient.

Google batch files / MS-DOS commands
 
Upvote 0
You could do this in Excel VBA:

Code:
Public Sub DeleteOldFolders()

Const MyParentFolder = "S:\CCTV Downloads\Downloads"

Dim fso As Object
Dim parentFolder As Object
Dim subFolder As Object

Set fso = CreateObject("Scripting.FileSystemObject")
Set parentFolder = fso.GetFolder(MyParentFolder)

For Each subFolder In parentFolder.SubFolders
    If subFolder.DateCreated < Date - 30 Then
        subFolder.Delete True
    End If
Next subFolder

End Sub

WBD
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,107
Members
452,302
Latest member
TaMere

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