Revision Numbers for Visio Diagrams

Started by Tegglet, July 16, 2014, 12:18:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tegglet

MS word has a field that updates each time the file is saved called revnum.  This is nice and simple and does what it says on the tin.  The biggest problem is finding it amongst the untidy clutter we now have to plough through to find things >:(.

Is there not a similar feature lurking in some dark and dank corner of Visio?  All I want to do is add a quick and simple field to say the file has been changed, or at least saved.

I have tried using the =DOCLASTSAVE() function but this does not update the time (useful when working up a new diagram).  The only good thing is that I can find it by clicking the Insert tab followed by Field.  MS Word hides it under Quick Parts for some mysteries reason.

Can anyone tell me if an equivalent to revnum exists in Visio and where to find it or if not how I get the time to update in the =DOCLASTSAVE() function.

wapperdude

You're on the right track.  Go back to the Insert Field and change the Data Format.  This will bring up another form, use the Format scroll arrow to select the desired date configuration.  The result will appear in the Custom Format cell.  Click OK.

Wapperdude
Visio 2019 Pro

Tegglet

Thanks for your response but it is not quite what I am after.

I really want a number rather than a date as I am finding the various date formats a tad unpredictable and long winded.  Adding the time to the field seems to update the time sporadically regardless of whether any changes have been made to the document and leaving it off does not record multiple changes made during the course of a day.

I would have thought the MS Word revnum field would be available in Visio, after all this is the simple solution and word and Visio are both part of the same suite.

Not to worry, I will have to muddle along as usual.

Many thanks for your response.

Yacine

I you don't mind using a VBA macro, you could do the following.
Add a custom property to your document and name it "prop.rev" or similar.
Catch the "Document_BeforeDocumentClose" event.
Get the value of "prop.rev", increment it by one, save the document, done.
Yacine

Tegglet

Hi Yacine,
Thanks for the suggestion, it looks as if it will do the job.  I don't mind using a VBA macro, I just don't know how to do what you suggest! :(  I have had a bit of a click about but can't find anything helpful, would you mind giving me a step through.

Is there a "Document_BeforeDocumentSave" event as that would be even better.

Yacine

#5
sure, but that would increment the variable for each saving, which may occur several times in one session.
Putting the code however in BeforeDocumentClose does not save the change to the variable.
Calling a save in this procedure does save the document, but causes also Visio to crash.
I don't know if someone else has a better idea to overcome this crash.

Private Sub Document_BeforeDocumentSave(ByVal doc As IVDocument)
    temp = doc.DocumentSheet.CellsSRC(visSectionProp, 0, visCustPropsValue).FormulaU
    temp = temp + 1
    doc.DocumentSheet.CellsSRC(visSectionProp, 0, visCustPropsValue).FormulaU = temp
    Debug.Print doc.DocumentSheet.CellsSRC(visSectionProp, 0, visCustPropsValue).FormulaU
End Sub

Yacine

AndyW

Better do do this on the document close events, just need a flag to remember if the document has been saved. If so update the revision and save it again. Also, this wa the revision only increments on the final close and not any intermediate saves.

Private updateRevision As Boolean

Private Sub Document_BeforeDocumentClose(ByVal doc As IVDocument)
    If updateRevision Then
        temp = doc.DocumentSheet.CellsSRC(visSectionProp, 0, visCustPropsValue).FormulaU
        temp = temp + 1
        doc.DocumentSheet.CellsSRC(visSectionProp, 0, visCustPropsValue).FormulaU = temp
        doc.Save
    End If
    Debug.Print doc.DocumentSheet.CellsSRC(visSectionProp, 0, visCustPropsValue).FormulaU
End Sub

Private Sub Document_BeforeDocumentSave(ByVal doc As IVDocument)
    updateRevision = True
End Sub
Live life with an open mind

Yacine

Have you tried it? When I saved the doc from within the beforeclose procedure, visio crashed.

But your idea is still good. Just that I would increment on the first saving only and won't use the beforedocumentclose anymore.
Yacine

AndyW

Live life with an open mind

wapperdude

Couple of points:
  1.  Seems like a change document event should be captured and used to trigger the code to increment revision and then save.  Problem, not all change events warrant a revision update, e.g., viewing different pages, zooming in, etc.  So, code ought to ask if it is necessary to save.
  2.  Relying on user to save and using the save event as trigger is not guarantee...since the user might forget.  Visio will still ask to save, user says yes.  Code doesn't fire and revision not updated.
  3.  So, the code, like Visio, needs to ask if it should update the revision and save.
         >  Note, there are other document control issues if the document is referenced by many users...how many versions are out there, who's allowed to make changes, how do you know you have the most recent version, creating / storing a backup in case of unauthorized changes / crashes.

Finally, it seems like there could be a timing event issue.  Upon closing, Visio checks to see if document has been saved.  Does running the code to do an edit (change revision, and save) create a timing conflict?  Is that why running the code causes a Visio crash?

Anyway, just some observations and thoughts.

Wapperdude
Visio 2019 Pro

Jumpy

A observation from the side:
It doesn't seem usefull to use and display a revision number, if you always only "Save" the document. It would be more usefull after each revision to save the document with another name so the history of revision numbers has some sence.
So now, if I see document has revision number 8, I know that it was changed and saved eight times, but that is all. I don't now what have been the changes from 7 to 8, what has been in the older changes (1-7), who did the changes and so on.

Or did I understand sth. wrong?

Yacine

Good point.
There should be a "new revision" macro, that saves the current doc under a new name, may be calls a dialog in which you may want to summarize the changes.
The macro could even set the old files in read-only.
Yacine

Paul Herber

As another reply from the side, I use CS-RCS revision control system to keep track of all my work changes. Not only does it keep old versions in an archive but also if files are in a text format them embedded keywords can be expanded to show the version number etc.
e.g.  $Revision: $
This even works with Visio files if in XML format (you also have to set the file types to be text rather than binary in CS-RCS's settings).
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Yacine

@Paul,
I had a quick search on the net. 100 USD is probably worth the money, but as "swabian" (I spent there 2,5 years and swanbians are Germany's scots) I ought to find an even cheaper solution.
Doesn't Visio itself provide a version control with the document managment tool? (I never got it to run, as I was asked to setup a server first)
Yacine

Paul Herber

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/