Tuesday, October 9, 2012

How to set expiry date for CATIA macros

Some users have applications where they need their CATIA macros to expire after a certain date. This is useful to force users to quit using an older version of a macro and upgrade to the latest one. This can be accomplished by adding an expiry date to your code. After the expiry date is crossed the macro will not run the program and will only display a message box telling the user the macro is expired.

We will be using the Date function which returns the current date only. Dates in VBA are stored as number so we have to use Format in order to display the date as something that makes sense for the user to see. myDate = Format(“11/11/12”, “DD/MM/YYYY”)

Our logic in this program will be this: If the current date is greater than the expiry date (later in the year) then the expired date has passed and the macro is no longer valid, so display a message box stating such. Otherwise, display a message box stating how many days are left before the macro expires (expiry date - current date).

Download the expiry date.catvba macro

Note, this is a CATVBA (not CATScript). Check out the CATIA macro downloads page for the complete code and other CATScripts and catvba macros.

No comments:

Post a Comment

I'd love to hear from you!