Solved

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

Posted on 2014-02-08
13
892 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
Comment Utility
Try application.window.top
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
Try
application.ActiveWindow.Top

gowflow
0
 

Author Comment

by:Kelvin4
Comment Utility
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
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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
Comment Utility
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
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Kelvin4
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi gowFlow:

This fits perfectly. Many thanks

Kelvin
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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
Comment Utility
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
Comment Utility
Well .... MS .... always have nice encouraging comments !!!
gowflow
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article will show you how to use shortcut menus in the Access run-time environment.
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now