Author Topic: Getting Invalid window type error which goes away when I click on the page  (Read 8140 times)

0 Members and 1 Guest are viewing this topic.

chrismartz

  • Jr. Member
  • **
  • Posts: 16
 




   
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

  • Jr. Member
  • **
  • Posts: 16
I didn't notice my typo on selectObj until after I posted. I fixed it and I still get the same error.

cwm

Jumpy

  • Hero Member
  • *****
  • Posts: 1061
What is the ActiveWindow, the moment your code works?

chrismartz

  • Jr. Member
  • **
  • Posts: 16
Hmmm . . .  at work, check when I get home. Sounds promising

cwm

chrismartz

  • Jr. Member
  • **
  • Posts: 16
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

  • Hero Member
  • *****
  • Posts: 1061
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

  • Jr. Member
  • **
  • Posts: 16
Thanks for the quick reply Jumpy - I'll give it a shot

Chris

chrismartz

  • Jr. Member
  • **
  • Posts: 16
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

  • Hero Member
  • *****
  • Posts: 1061
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/
« Last Edit: July 29, 2013, 04:54:05 AM by Jumpy »