Prevent the change of the page name

M

Mario Wilding

Hello!

Know someone, how can I prevent the change of a page name with VBA. I
use Visio 2003.

Thanks for answers.

best regards
Mario Wilding
 
J

JuneTheSecond

An idea might be to hide all page tags.
Sub HideTags()
'Hide Page Tags
Dim pg As Visio.Page
For Each pg In ActiveDocument.Pages
pg.PageSheet.Cells("UIVisibility").Formula = 1
Next
End Sub
Sub ShowTags()
'Show Page Tags
Dim pg As Visio.Page
For Each pg In ActiveDocument.Pages
pg.PageSheet.Cells("UIVisibility").Formula = 0 'Show
Next
End Sub
 
M

Mario Wilding

Thanks for the answer, but I nedd to see the pages. Any other idea?

best regards
Mario Wilding
 
A

Andy

You can't prevent the page rename. However, you can catch the
PageChanged event and then change the name of the page back.

For pages I don't want to be renamed, I have added a user defined cell,
called PageName in which I store the name of the page. I then catch the
PageChanged event on the Document. If a PageChanged event occurs, I
check if the page has the cell User.PageName and if so set the name of
the page back to the value stored in the cell.
 
J

JuneTheSecond

This is an example ready against moving page tags, it still restore page
name, if changed.

'on ThisDocument
Private Sub Document_DocumentChanged(ByVal doc As IVDocument)
Dim strPages As String
Dim pge As Visio.Page
For Each pge In ActiveDocument.Pages
strPages = strPages & " " & pge.Name
Next
DoUndo
End Sub

' on Standard Module
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal
hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
As Long

Sub DoUndo()
hwnd = Visio.Application.WindowHandle32
Call PostMessage(hwnd, &H111, &H3F9, hwnd)
End Sub

Sub DoRedo()
hwnd = Visio.Application.WindowHandle32
Call PostMessage(hwnd, &H111, &H3FA, hwnd)
End Sub
 
J

JuneTheSecond

Sorry, my code on ThisDocument should be replaced by
Private Sub Document_PageChanged(ByVal Page As IVPage)
DoUndo
End Sub
 

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