As close as I can get you to what you want is by putting the SAVED time and date on the idw.
Copy and paste the code below into your idw template. When you save your idw, this macro will write the "SysDate" and "SysTime" to a custom property in the idw. You can use a text box to put these parameters on your drawing.
Attached here is a shot of my title block where I write them onto the drawing.
Public Sub AutoSave()
Call AddSysDateTime
End Sub
Public Sub AddSysDateTime()
On Error Resume Next
'Check if the active document is a Drawing
If ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then
'Add a custom property "SysDate" with system date
Set oPropSet = ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
'As a workaround the property must be delete because it can not be changed
oPropSet.Item("SysDate").Delete
Call oPropSet.Add(Format(Date, "mmm-d-yy"), "SysDate")
'Add a custom property "SysTime" with system time
Set oPropSet = ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
'As a workaround the property must be delete because it can not be changed
oPropSet.Item("SysTime").Delete
Call oPropSet.Add(Format(Time, "h:mmam/pm"), "SysTime")
'Still having some problems that the last property does not update correct
Call RefreshProperties
End If
End Sub
Private Sub RefreshProperties()
Set oPropSet = ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
Call oPropSet.Add("", "MyDummy")
oPropSet.Item("MyDummy").Delete
End Sub
The CADWhisperer YouTube Channel
Niels van der Veer
Inventor professional user & 3DS Max enthusiast
Vault professional user/manager
The Netherlands
Glad it works for you. I have been using this for several years and it does work great. Wish I could take the credit for it, but I got this from this forum many moons ago. ( I think it was from an adesk person)
To get rid of the warning message, can you not disable the message by selecting the "Never show this thing again" button. It is behind the promt button on the warning message. They added this sometime ago just to warn people if they have overblotted VBA code in the idw. I think there is a performance issue when you open several idws in the same session. I can have several idws open at the same time and I don't have an issue. But if I tried to open say 100 idws in the same session, it might get bogged down.
If you don't need the variable, just remove it from the code. If it was me, I would just leave it there, never know if you will need it later. I don't know what the difference is in file size with and without the systime written to the custom prop. I am sure it is a very small difference.
Niels van der Veer
Inventor professional user & 3DS Max enthusiast
Vault professional user/manager
The Netherlands
Thanks karthur for sharing that code.. it's perfect !!!
I know this is really old. I have been using this for many years now and it has worked great. Now it suddenly will no longer update the time and date when I save. I have tried to repast the code into VB but that has not changed anything. Anyone have any ideas.
I am still running XP and Inventor 8
Hi Jeff,
I believe it should be working. I don't have Inventor R8 to test. Even if there was a bug, there isn't much I can do right now since it is too old and it is no longer a supported product on a discontinued platform. Could you upgrade to more recent release?
Many thanks!
Here is the code that I use for the date/time plot stamp (and it's ilogic, not VBA).
'' ilogic rule to automatically place and update plot date stamp to *idw sheets '' created 04.dec.2017 -- DJ 'Gets the active document Dim odrawdoc As DrawingDocument odrawdoc = ThisApplication.ActiveDocument 'Gets the Inventor Property Set Dim customPropertySet As PropertySet customPropertySet = odrawdoc.PropertySets.Item("Inventor User Defined Properties") 'Declares date and time as string Dim PlotDate As String PlotDate = Now() Try customPropertySet.Item("Plotdatestamp").Value = PlotDate Catch customPropertySet.Add(PlotDate, "Plotdatestamp") End Try InventorVb.DocumentUpdate()
I've been using it for approx. 1 year and have had no problems. The code changes the time & date every time it is printed (maybe even every time it is saved).