Solved

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

Posted on 2014-02-08
13
913 Views
Last Modified: 2014-02-12
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
Comment
Question by:Kelvin4
  • 6
  • 6
13 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 39845002
Try application.window.top
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39846886
Try
application.ActiveWindow.Top

gowflow
0
 

Author Comment

by:Kelvin4
ID: 39847240
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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 29

Expert Comment

by:gowflow
ID: 39847673
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
 

Author Comment

by:Kelvin4
ID: 39847926
Hi gowflow,
   Thanks indeed!
   Speed is not an issue, and I will keep this question open for you.

Kelvin
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39847965
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
 

Author Comment

by:Kelvin4
ID: 39850448
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
 

Author Comment

by:Kelvin4
ID: 39850851
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
 
LVL 29

Accepted Solution

by:
gowflow earned 500 total points
ID: 39852579
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
 

Author Closing Comment

by:Kelvin4
ID: 39852746
Hi gowFlow:

This fits perfectly. Many thanks

Kelvin
0
 
LVL 29

Expert Comment

by:gowflow
ID: 39852773
Well glad we pulled this one to your satisfaction as frankly I was seeing no light in the Visio issue !!! :)
gowflow
0
 

Author Comment

by:Kelvin4
ID: 39852943
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
 
LVL 29

Expert Comment

by:gowflow
ID: 39853082
Well .... MS .... always have nice encouraging comments !!!
gowflow
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question