• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 964
  • Last Modified:

How to to specify .top and other position parameters of Visio 2013 Application Window

In Excel, Application.top enables a new top value to be set for the application, but
In Visio, Application.top does not exist.

In Visio, I can access the Application window, as evidenced by the following:  
Application.Window.Caption = Visio Professional
Application.Window.type =  5

But Application.Window.is 'READ ONLY' (and unsurprisingly has no  .Top  property).

The Visio Application Window (which can contain file: Slave.VSDM) needs to be positioned in relation to the position of the Application Window of an Excel Application instance, whose .XLMS file opens the Visio Application and creates/controls the Slave.VSDM file.

How do I use automation to control the position of the Visio Application window? If it requires inter-operability and a ThisAddIn class in Visio to access more of the visio object model, then this would be new work for me.  I dont have Visual Studio.


Thanks, Kelvin4 (vba user) .
0
Kelvin4
Asked:
Kelvin4
  • 6
  • 6
1 Solution
 
Saqib Husain, SyedEngineerCommented:
Try application.window.top
0
 
gowflowCommented:
Try
application.ActiveWindow.Top

gowflow
0
 
Kelvin4Author Commented:
Syed:  thanks for application.window.top .        This was discussed in my question viz:
"In Visio, I can access the Application window, as evidenced by the following:  
Application.Window.Caption = Visio Professional
Application.Window.type =  5
But Application.Window.is 'READ ONLY' (and unsurprisingly has no  .Top  property)."

==============================

Gowflow: thanks for application.ActiveWindow.Top .     This returns a type 1 window (in my file, that's the Drawing window).

I think 'ActiveWindow' accesses the Application.WindowsCollection, whereas to get at the top-level application window, one needs Application's window object  (ie not its subordinate windows collection).

===============================

I think this means I need Microsoft interoperability to get at more Visio Application level properties (ie a read and write  .Top property).

I'm hoping that an Expert can at least confirm the inaccessibility of the positional dimensions of Application.window from the standard Visio object model...

... And an Expert to comment on whether this is a job for interoperability, or is perhaps just a dead end (though clearly the visio application window must know its own dimensions.

Kelvin
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
gowflowCommented:
I see you already asked your question on window forum
http://answers.microsoft.com/en-us/office/forum/office_2013_release-visio/how-to-access-the-top-parameter-for-the-visio-2013/06cf31b0-6ad2-42fa-bc87-524b8f55ccf6

Let me see what I can gather ... hv to be patient. Unfortunately I do not have Visio on my machine but recall I had a copy sometime somewhere will look around to find it, and just sake challenge ready to install it on my machine to see how to help u

Hang in there
gowflow
0
 
Kelvin4Author Commented:
Hi gowflow,
   Thanks indeed!
   Speed is not an issue, and I will keep this question open for you.

Kelvin
0
 
gowflowCommented:
for me ?
u mean for you !!!

I found the Visio but it says need to install Visual Studio first !!! which also don't have.

Will look around to see If I can find something for you. Will revert.
gowflow
0
 
Kelvin4Author Commented:
gowflow:
Oh yes, excuse me, I meant for me (to remove any implied time pressure on you).

Here, is a response to my MS Office Community question.
My first plan will be to see if I can get it to work in Visio. Then, if so, wonder how to use it interoperatively in Excel.

http://answers.microsoft.com/en-us/office/forum/office_2013_release-customize/accessing-a-visio-applicationwindow-property-via/cefbcf36-fb18-4b82-8753-9f46e16a37f0

Kelvin
0
 
Kelvin4Author Commented:
Hi gowFlow:

re above, this url.....

http://answers.microsoft.com/en-us/office/forum/office_2013_release-customize/accessing-a-visio-applicationwindow-property-via/cefbcf36-fb18-4b82-8753-9f46e16a37f0

... contains a VISIO sub called Test(). When Visio.Test is driven from a cmd button on the visio drawing window then, when that button is actuated, the visio application window moves over the excel window. Brilliant! If you define the version of visio application you have (2013/2010..etc), I will forward you the demo files for interest.

This, if excel could detect the movement of the application window by the author.  I could drive Visio.Test from excel.  However, I dont see an Excel.Application EVENT in the excel object model that responds to cell movement, so a work around seems to be needed.

One work-around might be to get Excel.Application.Top to display dynamically in a workbook cell, then the worksheet cell change EVENT could be used to detect a change in .top value. Though the ultimate aim is to trigger the visio.Test sub provided in the URL above, initially a model test within Excel would be fine, triggering excel.MsgBox "The Application Window moved".

So my question has advanced to ask either:
 -- can Excel.Application.Top can be displayed dynamically in a workbook cell, or
 -- how else can I make this vital link between Excel.Application movement and activation of a MsgBox response in Excel.

Failing an answer to one of these queries, the existing code gives me a new and useful, non-dynamic facility.

Thanks for your interest.

Kelvin4
0
 
gowflowCommented:
Create a module in your workbook and paste the below code there
Put the following code in a Module in your workbook.

Sub ShowSizes()
Dim WS As Worksheet

With Application
    .EnableEvents = False
End With

Set WS = ActiveSheet

WS.Range("B1") = WS.Application.ActiveWindow.Top
WS.Range("B2") = WS.Application.ActiveWindow.Left
WS.Range("B3") = WS.Application.ActiveWindow.Height
WS.Range("B4") = WS.Application.ActiveWindow.Width


With Application
    .EnableEvents = True
End With

End Sub

Open in new window


and then in the sheet you want to show the results put in the
Worksheet_SelectionChange and
Worksheet_Change event events this:
ShowSizes

and also in Thisworkbook event
Workbook_WindowResize
ShowSizes

Unfortunately Excel does not trap Click events so this is the best way to get these figures. If you move the sheet around the figures will only be updated once you click on a cell on the sheet or change anything in a sheet or resize the sheet.

Hope this helps.
chk the attached file.

gowflow
WSSizes.xlsm
0
 
Kelvin4Author Commented:
Hi gowFlow:

This fits perfectly. Many thanks

Kelvin
0
 
gowflowCommented:
Well glad we pulled this one to your satisfaction as frankly I was seeing no light in the Visio issue !!! :)
gowflow
0
 
Kelvin4Author Commented:
Visio is a bit awkward at times. Despite the new xml type VSDM file format, I found it impossible* to customise the Fluent Ribbon of the Visio Drawing window  via XML. I needed it to be data driven - in the same way that's possible with the main Excel ribbon.

Hence the presence of Excel in my Visio project!

cheers -
kelvin

* and MS wrote to agree - it IS impossible!
0
 
gowflowCommented:
Well .... MS .... always have nice encouraging comments !!!
gowflow
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now