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

Posted on 2012-04-03
Medium Priority
Last Modified: 2012-07-08

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
Question by:Flying_High_71
  • 7
  • 6
LVL 31

Expert Comment

by:Scott Helmers
ID: 37810699
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:

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.

LVL 31

Expert Comment

by:Scott Helmers
ID: 37810707
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.

Author Comment

ID: 37811780
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 37825798
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" ?
LVL 31

Expert Comment

by:Scott Helmers
ID: 37827737
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.

Author Comment

ID: 37890412
Hi Scott

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

LVL 31

Expert Comment

by:Scott Helmers
ID: 37891924
Sorry -- lost this in the shuffle. I'm traveling the next couple of days but will get back to this.

Author Comment

ID: 37894809
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.
LVL 31

Expert Comment

by:Scott Helmers
ID: 38157938
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.

Author Comment

ID: 38158134
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.  

LVL 31

Accepted Solution

Scott Helmers earned 2000 total points
ID: 38159576
Actually, the macro doesn't update the shape on each page directly -- it uses a bit of Visio sleight of hand:
Each page contains a cell called "LastEditDate" in the User section of the ShapeSheet
The macro updates the user cell
The shape on the page includes a field that displays the contents of the user cell (plus a bit of text)
Consequently, your diagram requires two things:
Each page must contain User.LastEditDate
The shape that displays the date must contain a formula something like
="Last edit on this page: "&ThePage!User.LastEditDate
If you need help creating the user cells or inserting a field into a shape, just let me know -- neither is routine Visio knowledge though both will add to your "power user" skill set.

BTW, there is nothing in the macro that is version specific so it will run correctly with Visio 2007.
=  =  =  =  =  =  =  =  =  =  =  =  =  =
Addendum: I just learned something useful. When you copy a shape containing a field that references the User.LastEditDate cell in the page, Visio automatically adds the cell to the page. Consequently, you should be able to copy my shape to any page in another document and the appropriate cell will be added for you. In your previous response you said you received an error; was that when you were pasting my shape into your document or at some other moment?

Author Comment

ID: 38165266
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!
LVL 31

Expert Comment

by:Scott Helmers
ID: 38165339
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.

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A recent Visio zone question asked how to use the data in an Excel file to create a Visio Gantt chart -- and then to dynamically update the Gantt chart. The good news is that the Viso Gantt Chart wizard can be automated. The bad news is that the…
David Parker’s latest book, Microsoft Visio 2010: Business Process Diagramming and Validation, will give you the tools to turn flowcharts and other business diagrams into valuable, data-driven corporate assets. Armed with the knowledge you’ll gain f…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question