Solved

MS Word VBA - Determining Ribbon State on Open Combined with Toggle Event

Posted on 2016-07-25
3
36 Views
Last Modified: 2016-09-14
I have the same issue as another question posted on this site.

I'm having the same issues as Mike235, whereas the calculation of the ActiveWindow.UsableHeight property does not update the value within the same subscript following a .ToggleRibbon event.  There really is quite a paucity of information relating to the .ToggleRibbon script in MS Word, and I've spent a good amount of time looking for a solution.

The basic idea is that the application will recognize the ribbon state (visible or minimized) when the document is opened, and either activate the toggle ribbon command, or do nothing (if the ribbon was already minimized).  Additionally, I would like to have a close event that restores the ribbon to it's original state when the application was opened (i.e. either maximized or minimized).

Very simple to explain, and it also seems like the above code *should* work, although as you've demonstrated, this isn't the case.

I've tried implementing the latter code provided by DrTribos, although this isn't restoring the application window state back to having the ribbon visible when the document is closed and the application is exited.  I've been experiencing these issues in both MS Word 2010 & 2013.

Any further insight would be much appreciated.
0
Comment
Question by:Mark Delorme
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
xtermie earned 500 total points (awarded by participants)
ID: 41765230
Please see attached script (VB) that checks if ribbon is visible and minimizes
Function xxx(Params)   
set application=getobject(,"word.application")
xxx= -2
On Error Resume Next
if Application.ActiveDocument.CommandBars("Ribbon").Height>100 then
application.ActiveWindow.ToggleRibbon
    end if
end function 
wscript.echo xxx(11)

Open in new window


To restore use the opposite check
Function yyy(Params)   
set application=getobject(,"word.application")
yyy= -2
On Error Resume Next
if Application.ActiveDocument.CommandBars("Ribbon").Height<100 then
application.ActiveWindow.ToggleRibbon
    end if
end function 

wscript.echo yyy(11)

Open in new window

0
 

Author Comment

by:Mark Delorme
ID: 41770770
@xtermie:  This code does not work unfortunately.  I've tried everything; I'm thinking that it might not be possible.
0
 
LVL 18

Expert Comment

by:xtermie
ID: 41797493
script and suggestions work
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.

691 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