Visio Guy

Visio Discussions => Programming & Code => Topic started by: tlpd on April 05, 2010, 11:04:14 AM

Title: Using Application variable in Visio 2000
Post by: tlpd on April 05, 2010, 11:04:14 AM
I have a method used to reset the window size after opening as below
Sub ResetWindow()
   Dim xPos as Integer
   Dim yPos as Integer
   Dim width as Integer
   Dim win as Visio.Window
   Set win = Application.Window
   Dim hWnd as Long
   hWnd = win.WindowHandle32
   
   Dim ret as Long
   xPos = GetSystemMetrics(0)
   yPos = GetSystemMetrics(1)

   width = xPos / 2

   ret = SetWindowPos(hWnd, HWND_TOP, width - 2, 0, width + 2, yPos - 34, SWP_NOSIZE)
   
End sub


This code worked perfectly in Visio 2003, but when i executed it using Visio 2000, a [Error '438' Object Doesn't Support This Property Or Method] error was generated at [Set win = Application.Window]. The reason seems to be that [Application] variable is not recognizable or not supported in Visio 2000. So i wonder if there is a way to handle this problem.

Thank you very much in advance
Title: Re: Using Application variable in Visio 2000
Post by: Nikolay on April 05, 2010, 11:34:36 AM
Instead of:

   Dim win as Visio.Window
   Set win = Application.Window
   Dim hWnd as Long
   hWnd = win.WindowHandle32


Try this:

   Dim hWnd as Long
   hWnd = Application.WindowHandle32
Title: Re: Using Application variable in Visio 2000
Post by: tlpd on April 08, 2010, 12:49:52 PM
Thank you very much. it worked perfectly