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

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

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
Mark Delorme
Asked:
Mark Delorme
  • 2
1 Solution
 
xtermieCommented:
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
 
Mark DelormeAuthor Commented:
@xtermie:  This code does not work unfortunately.  I've tried everything; I'm thinking that it might not be possible.
0
 
xtermieCommented:
script and suggestions work
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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