Getting Invalid window type error which goes away when I click on the page

Started by chrismartz, July 21, 2013, 04:38:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

chrismartz

 




   
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


chrismartz

I didn't notice my typo on selectObj until after I posted. I fixed it and I still get the same error.

cwm

Jumpy


chrismartz

Hmmm . . .  at work, check when I get home. Sounds promising

cwm

chrismartz

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

Jumpy

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.

chrismartz


chrismartz

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

Jumpy

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/