![]() |
|
|
Thread Tools | Display Modes |
#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 |
|
![]() |
||||
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 |
![]() |
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 |
![]() |
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 |