|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Use some sort of onload function to check whether template version uses the latest template.
For example, the document knows it is version 3.1 (because, for example, that number is written in a textbox somewhere) and then the document macro goes and checks a different file that has the latest version number. Then, the macro communicates to the user (by a message box? or in the header of the document?) whether or not that version is the latest version (For example ("this document is using version X, the latest version is version Y") X and Y could be numbers or dates or both. I'd really love some help on this, I haven't coded in a while (but I do have experience coding in vba in the past) |
#2
|
||||
|
||||
Whatever template a document is attached to will always be the current one. So, updating a template means the document is attached to the updated one. That's quite a different issue from whether the document reflects the current template, however, and simply changing templates doesn't propagate anything to the documents created from it; the most that will be updated is Style definitions, and even that will only occur if the document has been saved with the 'automatically update document styles' attribute.
It's easy enough to use document properties or document variables to hold template versioning data but, other than the alert, to what end do you propose to put the comparison? And what about documents that don't have their template version recorded or weren't originally attached to your template but now are?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Hi macropod, thanks for the reply!
Your questions and points are good and get into a lot of things.. I'm pretty sure the end goal we want is to be able to be aware when a document uses the latest approved language in particular sections when the document is being passed around through different levels of management. The way we want to accomplish that is with keeping track of what "template version" is being used. IE if someone turns a document into upper management that says "This document uses template 4.1 , the latest template is 4.2" they will know that before they give final sign off, the 'boiler plate' language will have to be changed. |
#4
|
||||
|
||||
I think you'll find the kind of use to which you want to put the versioning is unreliable. All that needs to happen to undermine the example you gave is for someone to copy some content from a document based on a 4.1 template - or even a document not based on any of your numbered templates - into a document based on a 4.2 template.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Ok, fair enough. Thanks for the reply. So what's your suggestion then?
|
#6
|
||||
|
||||
Well, testing and reporting whether a variable/property stored in a document is the same as the one stored in the attached template is easy enough, but I'm not sure what that achieves - it may actually provide false comfort.
Having said that, if you still want to go down that path, you could open the template for editing and set it's version with code like: Code:
Sub SetTemplateVersion() Dim SngVer As Single With ActiveDocument On Error GoTo ErrExit If .Variables("TemplateVersion") Is Nothing Then SngVer = InputBox(Prompt:="Please input the Template Version #", _ Title:="Template Version Input", Default:="1.0") .Variables.Add Name:="TemplateVersion", Value:=SngVer Else SngVer = InputBox(Prompt:="Please input the Template Version #", _ Title:="Template Version Input", Default:=Format(.Variables("TemplateVersion").Value, "0.0")) .Variables("TemplateVersion").Value = SngVer End If MsgBox "The Template Version has been set to: " & Format(.Variables("TemplateVersion").Value, "0.0") .Save End With ErrExit: End Sub Code:
Private Sub Document_Open() Application.ScreenUpdating = False Dim Tmplt As Document, SngVer As Single, StrMsg As String With ActiveDocument Set Tmplt = .AttachedTemplate.OpenAsDocument With Tmplt On Error Resume Next SngVer = .Variables("TemplateVersion").Value On Error GoTo 0 .Close False End With If .Variables("TemplateVersion") Is Nothing Then StrMsg = "This Document has no record of its Template Version." ElseIf .Variables("TemplateVersion").Value <> SngVer Then StrMsg = "This Document is based on Template Version: " & Format(.Variables("TemplateVersion").Value, "0.0") End If MsgBox StrMsg & vbCr & "The Current Template Version is: " & Format(SngVer, "0.0") End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
macro, onload, version |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Template not read properly even after enabling compatible with latest version | ashwini | PowerPoint | 1 | 12-17-2014 02:35 AM |
When creating new template from established template macros getting lost. | TechEd | Word | 3 | 06-09-2014 07:22 PM |
Add a word 2010 function to template | Esgrimidor | Word VBA | 4 | 02-23-2014 06:59 AM |
Automatic update of links in template - closing attached template without saving | stefaan | Word | 2 | 11-02-2013 07:46 AM |
ActiveX controls inserted on a template do not function well | ged | Word | 0 | 10-21-2010 04:53 AM |