Visio Guy

Visio Discussions => Visio 2010 Issues => Topic started by: chrismartz on July 21, 2013, 04:38:36 AM

Title: Getting Invalid window type error which goes away when I click on the page
Post by: chrismartz on July 21, 2013, 04:38:36 AM
 




   
Dear all -

I'm trying to move a callout after I drop it but I'm getting the  message below. I run the code and get the error message on the highlighted line. I can see on the page that the text box is selected. If I click on it to deselect and then click again  to select I can then run the code but get another error the next time I hit the line.

Any Ideas?

Thanks Chris

Run-time error '-2032465755(86db08a5)':
Invalid window type for this action


  Set callout = callouts.Masters("Text callout")
      Dim results As Visio.Shape
      Set results = pagObj.DropCallout(callout, vsoShape(CurrentTask))
      results.Text = PrintString
      results.Cells("Char.Size").Formula = "= 6 pt."
      Dim selecttObj As Shape
      Set selectObj = ActiveWindow.Selection
      If selectObj.Count = 0 Then
        MsgBox "You must select a shape first."
     Else
         ActiveWindow.Selection.Move (2 * ObjectWidth), -(ObjectWidth * 2)
      End If

Title: Re: Getting Invalid window type error which goes away when I click on the page
Post by: chrismartz on July 21, 2013, 04:42:04 AM
I didn't notice my typo on selectObj until after I posted. I fixed it and I still get the same error.

cwm
Title: Re: Getting Invalid window type error which goes away when I click on the page
Post by: Jumpy on July 21, 2013, 08:05:15 PM
What is the ActiveWindow, the moment your code works?
Title: Re: Getting Invalid window type error which goes away when I click on the page
Post by: chrismartz on July 22, 2013, 12:27:44 AM
Hmmm . . .  at work, check when I get home. Sounds promising

cwm
Title: Re: Getting Invalid window type error which goes away when I click on the page
Post by: chrismartz on July 24, 2013, 07:58:46 AM
Thanks Jumpy that seems to be the problem. ActiveDocument changes when I open the stencil I need. Now my problem is I can't find the syntax to set the ActiveDocument to ThisDocument.

Any ideas?

Thanks,

Chris
Title: Re: Getting Invalid window type error which goes away when I click on the page
Post by: Jumpy on July 24, 2013, 08:38:01 AM
You could either store the ActiveWindow in a variable prior to opening the stencil.
Same is true if you are not working with a Window but a document?

Or you can iterate through Visio's (the Applications) Windows collection and somehow identify the Window you want.
Title: Re: Getting Invalid window type error which goes away when I click on the page
Post by: chrismartz on July 24, 2013, 09:13:32 AM
Thanks for the quick reply Jumpy - I'll give it a shot

Chris
Title: Re: Getting Invalid window type error which goes away when I click on the page
Post by: chrismartz on July 27, 2013, 08:16:59 AM
Thanks Jumpy - your suggestions have worked. I need to ask a question though, instead of reading through all of the pages is there some simple way to just make the page I want active. For example.

Dim WriteToPage as Visio.Page
Set WriteToPage = ThisDocument.Pages.Add
WriteToPage.Name = CriticalStream
' go to some other documents and pages
' Then I would think there would be a command like
WriteToPage.Select ' or something.

Thanks Chris
Title: Re: Getting Invalid window type error which goes away when I click on the page
Post by: Jumpy on July 29, 2013, 06:30:25 AM
I have no Visio at the moment, but you can set the active page somehow. Maybe it was via the window???

ActiveWindow.Page:=WriteToPage    ?

Edit: Example:
http://www.visguy.com/2006/11/08/combo-box-table-of-contents/