How to refresh shapes when linked to a db

D

Doug Finner

I'm trying to learn how to connect shape characteristics to
db records. I have had some success. If I connect a
background color to a db record, modify the record, and
then run the macro (Tools - Macros - Visio Extras -
Database Refresh), the color changes.

What I'd like to do is two things:
A) - have the Visio drawing refresh every time it is opened.
B) - provide an 'on demand' method for users to refresh the
drawing without going through all the menu structure to run
the macro - I'm thinking a button they can single click.

I'm having no luck find a way to launch a macro and don't
know how to programmatically force a db refresh. Any help
is appreciated.

Doug
 
A

al

Dave Follett posted this excellent note several weeks
ago...
From Page 759 of Microsoft Visio Version 2002 Inside and
Out book.

1) Tools / Macros/ Visio Extras / Database Wizard
2) Click Next
3) Select "Create A Linked Drawing or Modify An Existing
One", and click
Next
4) Select "Add Database Actions And Events To a Drawing
Page", and click
Next
5) Choose your Visio Drawing and page
6) Check the "Refresh linked shapes on document open", and
click Next
7) Click Finish

I tried this out a while back and was disappointed because
you have to do
this for every page that contains a linked shape and my
visio document
contained more than a hundred pages. So wrote a macro
that loops through
all pages refreshes them with the database. I'm sure
there is a way to make
the macro run when the document opens although I don't
know what it is off
hand. Hope this helps.


' DatabaseRefresh
'
' This macro loops through all pages of your visio
document and
' performs a Database Refresh by executing the Addon for
refreshing
' the database ("Database Refresh").
Public Sub DatabaseRefresh()
Dim pg As Visio.Page
Dim OriginalPg As Visio.Page

' Record the original page
Set OriginalPg = ActiveWindow.Page

' Loop through each page of the document
For Each pg In ThisDocument.Pages

' Set the page to be the active page
ActiveWindow.Page = pg.Name

' Execute the "Database Refresh" Addon
Application.Addons("Database Refresh").Run ""

' Increment the page counter
Next pg

' Set the active page back to the original one so the
' user doesn't end up on the last page
ActiveWindow.Page = OriginalPg.Name

End Sub
 
D

D Finner

Al,
Thank you for posting this. I'm not having much luck with
the 'db wizard' method - I seem to be running into more
than the 7 steps you show but that may just be Monday
morning brain lock.

The macro is a huge help - it provides information on how
to call the add on macros that come with Visio, exactly
what I needed.

Many thanks for the help.

Doug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top