Link to home
Start Free TrialLog in
Avatar of Flying_High_71
Flying_High_71Flag for Australia

asked on

Visio 2007 - How to set the Last Edit Date to be at a page level rather than file level

Hi EE

I have a Visio 2007 with several pages describing different but related business processes.

I am seeking to set a last edit date at a page level, however the standard approach of using the menu option 'Insert > Field > Date/Time / Last Edit Date/Time' works at a whole of file level rahter than when the specific page was changed.  I would like to track the date when the individual pages were last edited, not when the file was last edited.

Can you advise how I can insert a field that will show the 'Last Edit Date' to be at a page level rather than file level?

Many thanks
FH
Avatar of Scott Helmers
Scott Helmers
Flag of United States of America image

I'm not aware of a way to have Visio do this for you, but you could accomplish it with some VBA code. The required code won't require rocket science but neither will it be a garden variety recorded macro. I think you'll need something like this:

Setup
Create user cell on each page to hold last edit date, e.g., User.PageChangeDate
Experiment with the Visio Event Monitor (part of the Visio SDK) to determine which Visio events will catch the kinds of changes you're interested in
Code Logic
When an event fires, determine which page contains the object that changed
Write current date to user cell defined above

As you can see the logic isn't particularly complex. The challenge will be to identify a set of events that capture the types of changes you want to know about without checking every possible event because that could affect the performance of Visio.

If you need assistance accomplishing the above, or want some sample code, just let me know.

Scott
I forgot one step under "Setup" in the post above: add a shape to each page that displays the value of the user cell, i.e., that displays the page's Last Edit date.
Avatar of Flying_High_71

ASKER

Hey thanks Scott

Just heading into Easter so it will be a few days before i get back to Visio to give your suggestion a crack.  Will let you know once I get back to it in a few days
Hi Scott

OK I am back.  

Some q's to kick off proceedings to the solution.
1. I have downloaded and installed the Visio 2007 SDK.  What this now means I have no idea, because I am not sure how that affects what I can see in the Visual Basic Editor within Visio 2007, because nothing looks any different.


2. When you say "Create user cell..." Do you mean:
 a. Create a text box
 b. Go to the menu and choose the option "Insert > Field > User-defined cells" ?
Creating a user cell involves using the Visio ShapeSheet. if you're not familiar with the ShapeSheet, take a look at this blog post from Visio MVP John Goldsmith: http://visualsignals.typepad.co.uk/vislog/2007/10/just-for-starte.html#more

A "user cell" is a row in the "User Section" of the ShapeSheet. You can use it to store data of any type.

I've experimented with this a bit this morning and haven't succeeded in finding the right combination of events that will trap what you need but won't overburden Visio with tracking zillions of little events we don't care about. I'll try to get back to this later in the week.

Don't worry about the SDK for now - we'll worry about the event monitor a bit further down the road.
Hi Scott

Did you make any progress on this.  I guess if not I may have to close it down...

cheerio
FH
Sorry -- lost this in the shuffle. I'm traveling the next couple of days but will get back to this.
No worries thanks.  I only ask because EE sent me the autogenerated 'abandoned question' so I wanted to be sure we know whether it can be done or not.
Better late than never??? Don't know whether you still need this but I've attached a document with macro code that automatically updates the "last saved" date on each page for the following events:
-- shape added
-- shape deleted
-- connection added
-- page name changed
-- data graphic added or removed
-- text changed

What it doesn't do is update for things like changing width, height, fill or shape attributes of that type. I can add that -- but it comes at a "cost" in performance. The performance might still be perfectly fine but I erred on the side of caution.
Last-edit-date-on-each-page-v01.vsd
Hi Scott

Thank you for that - certainly seems to work great, and is a far bigger macro than I would have thought required - wow - really good work.  

So I am just wondering, how the shape you have there is referred to by the Macro, i.e. "Last edit on this page: <date>" .  

I copied the macro itself just fine, but when I copy the shape, I get the dreaded "Visio Internal Error: #-1 Action 1021:Copy", to which the only work around I am aware of is an upgrade to Visio 2010.  We are using Visio 2007.

So if you could advise how I create my own shape to which the macro could refer, it would round this one out nicely.  

FH
ASKER CERTIFIED SOLUTION
Avatar of Scott Helmers
Scott Helmers
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great! So I will recap what I did in my Visio 2007.

For the ShapeSheet:
1. I opened the Visio menu Window > Show Shapesheet
2. The ShapeSheet window opened
3. I scrolled down to the section "User defined cells"
4. I right clicked in that section and selected the option "Insert Row"
5. In the new row, I added the cell User.LastEditDate and also added a default value
6. Save

For the macro:
1. I opened the Visio menu Tools > Macro > Visual Basic Editor
2. I copy and pasted the macro you provided in your attachment above into my Visual Basic Editor Window
3. I edited the subroutine "Sub UpdateLastEditCell(pg As Visio.Page)" to change the date format as required

For the shape iteself (in each sheet):
1. I created a new shape
2. I inserted a field using the menu option Insert > Field
3. In the dialog box that opens, under Category, I selected the option 'Custom Formula'
4. I entered a formula that read ="Last edit on this page: "&ThePage!User.LastEditDate

Presto! The field appears and now tracks the necessary changes.  Really happy with this outcome, but who would have thought this need be so much work...?

Now as regards your Addendum:
I too have found that if I copy the shape containing a field that references the User.LastEditDate cell in the page, Visio automatically adds the ShapeSheet cell to the page i.e. to the ShapeSheet.  However this is from the one I created using the above steps.  If I copy the one provided in the attachment, I seem to get the error above, at the point where I copy the shape i.e. inside your document.  

***
At any rate, the information you have provided is great and resolved this little black duck's problem, and taken me one step further to being an <ahem>  ...power... user and I use that term very loosely for mine :-)

Many thanks!
FH
You're quite welcome. I enjoy working on problems that involve something I haven't done before.

And thanks to you for posting the excellent recap. It will certainly help someone in the future who wants to accomplish the same thing.