Accessing window zoom from cell formula

Started by IRDC, July 02, 2010, 07:06:48 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

IRDC

Hi,
does anybody know a way to get information about the zoom level in a shape cell formula? I'd like to build shapes where the text stays roughly the same size when you zoom in on a group shape and so showing more of the group shape while not filling the screen with 200px high letters.

vojo

look up "docmd"  calls.   I think there is a bunch of zoom options in there....I know I use to call custom props  "docmd(1312)" from action tasks.

scott

Like you, I don't see a shapesheet function that reads the current zoom level, so I don't think you can do what you want entirely within the shapesheet.

However, you can use the ViewChanged event of the Window object to set a shapesheet cell value and then use that value any way you choose.

Create a user cell in the document sheet called
User.CurrentZoom
(or use any other name you'd like). Then add this code to the document
Public WithEvents wnd As Visio.Window
Private Sub Document_DocumentOpened(ByVal doc As IVDocument)
    Set wnd = ActiveWindow
End Sub
Private Sub wnd_ViewChanged(ByVal Window As IVWindow)
' ensure that the activewindow is the correct window, otherwise don't try to
' update the docsheet cell
    If ActiveWindow Is wnd Then
        ActiveDocument.DocumentSheet.Cells("User.CurrentZoom").Formula = wnd.Zoom
    End If
End Sub


Opening the document sets wnd to the active window and every time you change zoom levels, the line of code in wnd_ViewChanged will set the zoom value into the user cell.

Regards,
Scott