Automatically position the application window for Visio 2013

I use Excel 2010 and Visio 2013.
Excel file (name: 'XL_driver') creates/ selects a type of Visio file (name: 'vis_slave'), via early binding, and xl vba procedures control all vis-slave vba procedures.

I wish the XL-diver application window to appear on screen above vis_slave application window, so the USER can conveniently use xl's ribbon buttons to work with vis_slave. Thus, when the USER drags xl_Driver about the screen, its vis_slave should follow.

First steps in xl_driver code show evidence of progress (#2), but ultimate failure (#3):

1. Application.top and Application.height give the correct top and height values for the xl_driver app window

2. Accessing the visio application object model from Excel:
  'early binding
    Set visioApp = New Visio.Application
  'VisioApp is legitimate: the following exits visio application
  If Not visioApp Is Nothing Then visioApp.Quit
  Set visioApp = Nothing

3. 'Now try to position visio app window below foot of xl app window
    Set visioApp.top = Application.top + Application.height << BUG

Bug: 'Object does not support this property or method.
Problem: I cant find a path through the object model from visio application to .top

How do I do this, please?

Kelvin4
Kelvin4Asked:
Who is Participating?
 
Kelvin4Author Commented:
Below, I copy some stuff where WindowHandle32 object is defined via the ActiveWindow object. My problem is to set the top level Application window as an object as the first step.
 
Lets see what other advice we get,
Regards
Kelvin

http://msdn.microsoft.com/en-us/library/office/ff768775.aspx:

Public Sub WindowHandle32_Example()
 
 Dim vsoWindow As Visio.Window
 Dim lngWindowHandle32 As Long
 
 'Get the active window.
 Set vsoWindow = ActiveWindow
 
 'Get the 32-bit handle of the active window.
 lngWindowHandle32 = vsoWindow.WindowHandle32
 
 'Verify that you got the handle.
 Debug.Print "The active window handle is"; lngWindowHandle32
 
End Sub
0
 
Rgonzo1971Commented:
Hi,

After point 2 I do not see an "End If"
visioApp is already Nothing when your bug appear

EDIT Maybe

visioApp.ActiveWindow.Top

Open in new window


Visio.Application  has no Top Property

Regards
0
 
Kelvin4Author Commented:
Rgonzo,
Thanks, my text was not quite clear.  To clarify:  #2 was an independent bit of evidence that 'visioApp' is a legitimate object in my code ( though I inadvertently omitted 'End If' from the copied snippet ).

I confirm that in my development code, visioApp was not preceded by  Set visioApp = Nothing. So visioApp had value, but '.Top' was incorrectly assigned as a property in:
Set visioApp.top = Application.top + Application.height

Unfortunately in your EDIT: 'Top' is not a child property of the 'ActiveWindow' object either.

Kelvin
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Rgonzo1971Commented:
Hi,

in Visio you have the WindowHandle32  property

Private Declare Function MoveWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long

Public Sub Example() 
 
Dim vsoWindow As Visio.Window 
Dim lngWindowHandle32 As Long 

Set vsoWindow = ActiveWindow 
 
lngWindowHandle32 = vsoWindow.WindowHandle32 
 
lDone = MoveWindow(ByVal lngWindowHandle32, ByVal 0, ByVal 0, ByVal 1920, ByVal 1200, ByVal 1)
If lDone = False Then MsgBox "Failed" 
End Sub 

Open in new window

not tested
EDIT

to find the Application window you could loop them in Application.Windows and test for

Window.Type = visApplication ' 5
 
Regards
0
 
Rgonzo1971Commented:
Hi,


to find actual position pls try

Private Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As IntPtr, ByRef lpRect As RECT) As Integer


Private Structure RECT
    Public Left As Int32
    Public Top As Int32
    Public Right As Int32
    Public Bottom As Int32
End Structure


Dim visRect As RECT

lngWindowHandle32 = vsoWindow.WindowHandle32 
intResult = GetWindowRect(byVal lngWindowHandle32, visRect)

Open in new window

0
 
Kelvin4Author Commented:
Thanks, .... digesting!
0
 
Kelvin4Author Commented:
Hi, Rgonzo

I took up your text
<<<<      to find the Application window you could loop them in Application.Windows and test for Window.Type = visApplication ' 5     >>>>>

... and ran this sub  in a visio standard module:

Sub getDrawingWindow() ------------------------------------------------------------------
Dim win As Visio.Window

For Each win In Visio.Application.Windows
  Debug.Print "win.type = "; win.Type & "; win.subType = "; win.SubType & "; win.ID = "; win.ID
Next

'Debug.Print output was:  win.type = 1; win.subType = 128; win.ID =  8642

End Sub -------------------------------------------------------------------------------------------

win.type = 1 is the drawing window.
In this loop, I'm missing the Application window (win.type = 5)?

Can you advise, thanks
Kelvin
0
 
Rgonzo1971Commented:
Hi,

Somewhere I saw

Application.WindowHandle32

Could that be the solution?
0
 
Rgonzo1971Commented:
Hi,

pls try
Set visioApp = New Visio.Application 
lngWindowHandle32 =  visioApp.WindowHandle32 

Open in new window


Regards
0
 
Kelvin4Author Commented:
I'm afraid I do not know how to use your suggested start point (above).
I'm not certain it is so clear a start point, but if you can show it is, then I'd be delighted to pay you my points.

I believe a successful answer would provide a window object with window.type = 5.  
I do welcome a solution that demonstrates  that outcome.

thanks
0
 
Kelvin4Author Commented:
This a new part of the Visio object model to me

My question had a typo in it, and some clarification was needed.
The Expert gave me one important piece of information:
for the Application window: Window.Type = visApplication  , and value = 5.
I'd like to suggest that could be worth 80 points.

From the above advice, I then made some minor progress, but got no solution to the question that was clearly stated in the Title and subsequent text.

I now know that the Application Window object is accessed via:
Application.Window, for example:
Application.Window.Caption = "Visio Professional"

However, Application.Window is READ ONLY source: http://msdn.microsoft.com/en-us/library/office/ff769161.aspx 
.. and so position properties like .top .left etc do not exist.

Thus a different method of positioning the visio application window is required (if it exists).

I now wish to close this question fairly and ask another to meet the original need.

I appreciate the Experts' interest and input, but I suggest this question beat us both?
I am open to comment.

Kelvin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.