Author Topic: How to disable "Delete" page control?  (Read 305 times)

0 Members and 1 Guest are viewing this topic.

Gustavo

  • Jr. Member
  • **
  • Posts: 45
  • The ultimate inspiration is the deadline.
How to disable "Delete" page control?
« on: June 25, 2020, 03:24:28 PM »
Hi all

I'm building a solution and I'm strugling at disabling the controls/context menus for page insert, delete and change name that appears when right click in the name at the bottom of  Visio page. I've disabled the "Duplicate" page with the PageLockDuplicate cell of the page, but I don't know how to disable the other controls. Any toughts? is it possible a work around maybe with a msgbox warning?

Best regards.
« Last Edit: June 25, 2020, 03:41:42 PM by Gustavo »

Hey Ken

  • Full Member
  • ***
  • Posts: 218
  • Just This Guy
    • The Pennsylvania Project, with Ken Krawchuk
Re: How to disable "Delete" page control?
« Reply #1 on: July 07, 2020, 06:09:36 PM »
Gustavo:

   One thing I’ve done to stop unauthorized fiddling is to use VBA events to trap the bad behavior using the proper event handler, then simply undo it.  PageChanged traps renaming, DocumentChanged traps inserting pages, CellChanged can trap various Page Setup situations, etc., etc.  You can either use the plain old Undo, or if that’s insufficient, capture initial values via the DocumentOpened event, and whenever one of the other events fire, you can check to see if anything important has changed and then just change it back.  I’ve done this extensively in Excel VBA, and I’ve had some very frustrated users wondering why they couldn’t change anything.  Tee hee.  Might work for your situation too.  The most I’ve done in Visio is automatically delete any dropped shape I don’t approve of.  Lots of frustrated users from that one, too!

   Hope this helps,

   - Ken


P.S. Apologies for the delay in responding.  Been away having fun and ignoring the pandemic.
Ken V. Krawchuk
'caster

The Pennsylvania Project
Radio Podcast

10 to 11 AM Saturdays on WWDB 860 AM in Philadelphia
7 to 8 AM Mondays on KUR 1670 AM in Kutztown
On demand at http://PennsylvaniaProject.com

Croc

  • Full Member
  • ***
  • Posts: 246
    • Visioport
Re: How to disable "Delete" page control?
« Reply #2 on: July 08, 2020, 12:13:50 AM »
To block page deletion, it is enough to return TRUE in the Document_QueryCancelPageDelete event handler.

Code
Private Function Document_QueryCancelPageDelete(ByVal Page As IVPage) As Boolean
    Document_QueryCancelPageDelete = True
End Function

Gustavo

  • Jr. Member
  • **
  • Posts: 45
  • The ultimate inspiration is the deadline.
Re: How to disable "Delete" page control?
« Reply #3 on: July 08, 2020, 04:13:46 PM »
catch Events, of course! that's a clever solution I hadn't tought of... thank you Ken and Croc!