Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-15-2015, 01:30 PM
zzzjoshzzz zzzjoshzzz is offline Use some sort of onload function to check whether template version uses the latest template. Windows 7 32bit Use some sort of onload function to check whether template version uses the latest template. Office 2010 32bit
Novice
Use some sort of onload function to check whether template version uses the latest template.
 
Join Date: Oct 2015
Posts: 3
zzzjoshzzz is on a distinguished road
Unhappy 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)
Reply With Quote
  #2  
Old 10-15-2015, 07:09 PM
macropod's Avatar
macropod macropod is offline Use some sort of onload function to check whether template version uses the latest template. Windows 7 64bit Use some sort of onload function to check whether template version uses the latest template. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 10-16-2015, 01:37 PM
zzzjoshzzz zzzjoshzzz is offline Use some sort of onload function to check whether template version uses the latest template. Windows 7 32bit Use some sort of onload function to check whether template version uses the latest template. Office 2010 32bit
Novice
Use some sort of onload function to check whether template version uses the latest template.
 
Join Date: Oct 2015
Posts: 3
zzzjoshzzz is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 10-16-2015, 02:17 PM
macropod's Avatar
macropod macropod is offline Use some sort of onload function to check whether template version uses the latest template. Windows 7 64bit Use some sort of onload function to check whether template version uses the latest template. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #5  
Old 10-17-2015, 09:31 PM
zzzjoshzzz zzzjoshzzz is offline Use some sort of onload function to check whether template version uses the latest template. Windows 7 32bit Use some sort of onload function to check whether template version uses the latest template. Office 2010 32bit
Novice
Use some sort of onload function to check whether template version uses the latest template.
 
Join Date: Oct 2015
Posts: 3
zzzjoshzzz is on a distinguished road
Default

Ok, fair enough. Thanks for the reply. So what's your suggestion then?
Reply With Quote
  #6  
Old 10-17-2015, 10:31 PM
macropod's Avatar
macropod macropod is offline Use some sort of onload function to check whether template version uses the latest template. Windows 7 64bit Use some sort of onload function to check whether template version uses the latest template. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
You could leave that code stored in the template for ease of future use. Having stored it in the template, you could also run it against any existing documents based on the template to set their template version #s (assuming you know them). Then, to do a version check with any document based on the template when the document is opened, you could add the following code to the template's 'ThisDocument' code module:
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]
Reply With Quote
Reply

Tags
macro, onload, version

Thread Tools
Display Modes


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
Use some sort of onload function to check whether template version uses the latest template. 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
Use some sort of onload function to check whether template version uses the latest template. 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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:23 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft