Visio Guy

Visio Discussions => Programming & Code => Topic started by: perry59 on August 23, 2016, 04:23:58 PM

Title: active page always nothing
Post by: perry59 on August 23, 2016, 04:23:58 PM
title kinda says it all.
for some reason that's driving me nuts I cant get the active page from visio.
I can get the document just fine, like this...
Dim vsoDoc As Microsoft.Office.Interop.Visio.Document = Globals.ThisAddIn.Application.ActiveDocument

but even though I am looking at a drawing, the debugger always says my active page is nothing. these are the lines I'm using...

Dim vsoPage As Microsoft.Office.Interop.Visio.Page
vsoPage = Globals.ThisAddIn.Application.ActivePage 'this is returning nothing, why?

normally, I'd have those two lines concatenated like the activedocument one, I split it up when I started having problems
I hope someone can shed some light on this
Thanks
Title: Re: active page always nothing
Post by: Yacine on August 23, 2016, 04:30:30 PM
Do the other properties of the application return values (activewindow, activedocument, etc.)?
Title: Re: active page always nothing
Post by: perry59 on August 23, 2016, 05:15:56 PM
active document works as expected but even active window is "nothing" even though I can pull other properties from it like so...

If Globals.ThisAddIn.Application IsNot Nothing AndAlso Globals.ThisAddIn.Application.ActiveWindow IsNot Nothing Then
            If UCase(Microsoft.VisualBasic.Right(vsoDoc.FullName, 3)) = "VSD" Then
                window = Globals.ThisAddIn.Application.ActiveWindow
                currentDocument = window.Document.Name
            End If

here, window is "nothing" in the debugger, but "currentdocument" has the appropriate value
Title: Re: active page always nothing
Post by: perry59 on August 23, 2016, 05:28:42 PM
I found the answer here!
http://stackoverflow.com/questions/34545354/internal-error-in-the-expression-evaluator

its working now  ;D