Date change macro

TTevolve
Posts: 253
Joined: Wed Jan 05, 2022 10:15 am
Answers: 3
x 86
x 159

Date change macro

Unread post by TTevolve »

Date anyone have a macro that will change the date custom property for all parts in an assembly?

I love doing pack and go to copy an assembly and renumber it, but all the date custom properties need to get updated to the current date. I was hoping someone else has a macro that would update them all.
User avatar
gupta9665
Posts: 407
Joined: Thu Mar 11, 2021 10:20 am
Answers: 25
Location: India
x 431
x 447

Re: Date change macro

Unread post by gupta9665 »

Deepak Gupta
SOLIDWORKS Consultant/Blogger
TTevolve
Posts: 253
Joined: Wed Jan 05, 2022 10:15 am
Answers: 3
x 86
x 159

Re: Date change macro

Unread post by TTevolve »

gupta9665 wrote: Thu Mar 07, 2024 12:07 pm viewtopic.php?t=2578
I use that one all the time and it works great, the difference is I just want to enter the date, say 03/07/2024 and it changes all of them to that date.

The issue I have is sometimes the dates are not all the same if I did different parts on different days, so entering the value I want to change doesn't work. I would like it to just change every date custom property in each part to the date entered in the box.
User avatar
gupta9665
Posts: 407
Joined: Thu Mar 11, 2021 10:20 am
Answers: 25
Location: India
x 431
x 447

Re: Date change macro

Unread post by gupta9665 »

Can you share one sample file to understand?
Deepak Gupta
SOLIDWORKS Consultant/Blogger
TTevolve
Posts: 253
Joined: Wed Jan 05, 2022 10:15 am
Answers: 3
x 86
x 159

Re: Date change macro

Unread post by TTevolve »

Every part and sub-assembly in an assembly has a "Date" custom property. When I do a pack & Go to make a new version they do not update, and they can be different vales (ie. The screenshot below has 11/17/2023 as the date on one part, but the other part has 12/01/2023). I want the macro to change all the date custom properties on each part and sub assembly in the assembly to change to the date I input in the macro.

This part M-247-A has a date of 11/17/2023
image.png
This part M-247-A-B1 has a date of 12/01/2023
image.png
After I did the pack & go and created these parts as part of the new assembly I got to go in and change the date on each one, some assembly's have 30 or 40 parts where I have to open each one and change the date to 03/08/2024.
User avatar
gupta9665
Posts: 407
Joined: Thu Mar 11, 2021 10:20 am
Answers: 25
Location: India
x 431
x 447

Re: Date change macro

Unread post by gupta9665 »

The macro I have shared above should work OK.

Did you changed the number in below line to Date?

cpm.Add3 "Number", swCustomInfoText, mValue, 1
Deepak Gupta
SOLIDWORKS Consultant/Blogger
Post Reply