How to obtain system time, date and user for note in SW drawing

Hi,

Firstly, these forums have been a great help, and I thank everyone that contributes to them.

I am currently trying to update a macro which saves a pdf of the drawing, to include a small bit of text which time and date stamps the pdf. Although I don't expect we'll use this bit of data much, I know from previous experience that it can be useful should we have any errors in our drawing management process.

Is there a way to read and use the systems data and time in a solidworks macro?

The way I see the macro working:

User presses macro button,

does some checks for open file etc

save drawing file (if possible)

adds stamp which will contain the time (hhmmss), date (YYMMDD), and the user (Name) - Example 101643161206SHANEP (I wanted the part/assembly PDM version, and drawing version here as well, but we need PDM pro for that…)

Saves PDF in location specified by the ECN

Deletes stamp

Macro ends

I am having a lot of difficulty finding how to obtain the system time in a solidworks macro. Previous threads on this forum have suggested using SW-Last Saved Date, and SW-Last saved by… This will work, just not if drawing is in an Approved state in PDM – as it will just capture the last time it was saved.

Although the management process I am working on should stop this happening… I have no doubt it’ll happen, and I want to capture that information when it does happen.

Another way I had thought of getting the information was to have the macro open an excel sheet, excel gets the time and date stamp using a macro, copies the data out, then somehow feeds it back into the macro… but I can’t get that to work either.

As asked above, is there any way to read and use the system date and time in a solidworks macro? Like want can be done in  excel? Such as

NowText = Format(Now(), "hhmmssyymmdd")

Any help is greatly appreciated.

Kind Regards,

Shane

SolidworksApi macros