Dynamic userforms

E

EllenM

Hello,
I have created a Word template with a userform attached which appears
on-screen for the user to fill-in and subsequently insert information into a
letter. The macro which initiates this pop-up userform works great. However,
it would be nice to place a date field into the userform that displays the
date a developer last made a change to either the macro or userform
associated with my template. Essentially, I would like to have a dynamic
form in the sense that it displays the date when the template is saved. As
you know, changes to macros and forms only take effect when the associated
template is saved. I know this feature can be done with Javascript for
webpages. Is there something similar under the hood of VBA for Word?



I’m trying to take the headache away from the developers so they will not
have to manually insert a date each time they save changes to the macro
and/or form. Not only would this be invaluable to developers for quality
assurance but it would keep the end user informed to updates.



Thanks!

Ellen
 
J

Jay Freedman

Insert a label somewhere on the surface of the userform. Let's say you name
the label lblUFdate. Then in the UserForm_Initialize() procedure, include
code like this:

Dim SavedTime As Date
SavedTime = ThisDocument.BuiltInDocumentProperties( _
wdPropertyTimeLastSaved).Value
lblUFdate.Caption = Format(SavedTime, "yyyy-MM-dd HH:mm")

The format string shown here would result in the label showing something
like

2008-01-07 14:40

but you can change it if you prefer a different format. Note that
ThisDocument refers to the template where the macro is running, not to any
document that may be open at the time.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
E

EllenM

Thanks so much, Jay!!!!

Jay Freedman said:
Insert a label somewhere on the surface of the userform. Let's say you name
the label lblUFdate. Then in the UserForm_Initialize() procedure, include
code like this:

Dim SavedTime As Date
SavedTime = ThisDocument.BuiltInDocumentProperties( _
wdPropertyTimeLastSaved).Value
lblUFdate.Caption = Format(SavedTime, "yyyy-MM-dd HH:mm")

The format string shown here would result in the label showing something
like

2008-01-07 14:40

but you can change it if you prefer a different format. Note that
ThisDocument refers to the template where the macro is running, not to any
document that may be open at the time.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top