[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2016-07-25
3
Medium Priority
?
52 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

650 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