Change size of window when open visio

Started by tlpd, March 18, 2010, 05:13:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tlpd

I want to change the size of the Visio window when user click to open visio file (I mean change the size of the top window, not the size of the child window inside MDI).
Ex: i can do the below code to change size of the Excel window. However, when i applied into Visio, i does not work

With Application
   .WindowState = xlNormalState (i don't remember exactly)
   .Top = 0
   . Left = 0
   .Width = 500
End with

I want to do the same action with Visio, but still don't know how to implement!
So i wonder if someone would please give me some hints about this problem!

Thank you very much in advance!

JuneTheSecond

Hi, tlpd.

My idea is Windows API.
Visio has not hidden drawing like one in Excel,
and VBA cannot start without opening any drawing.
And then, you need to double click the drawing
that has VBA macro to set application window position and size.



Private Sub Document_DocumentOpened(ByVal Doc As IVDocument)
    test
End Sub





Declare Function SetWindowPos Lib "user32.dll" _
    (ByVal hWnd As Long, ByVal hWndInertAfter As Long, _
    ByVal x As Long, ByVal y As Long, ByVal cx As Long, _
    ByVal cy As Long, ByVal uFlags As Long) As Long

Sub test()
    Dim win As Visio.Window
    Set win = Application.Window
    Dim hWnd As Long
    hWnd = win.WindowHandle32
    Dim ret As Long
    ret = SetWindowPos(hWnd, HWND_TOP, 0, 0, 1000, 500, SWP_NOSIZE)
End Sub


Best Regards,

Junichi Yoda
http://june.minibird.jp/

tlpd

Hi JuneTheSecond,

I applied your method and it worked perfectly.
Thank you very much!