Solved

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

Posted on 2016-07-25
3
17 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
  • 2
3 Comments
 
LVL 17

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 17

Expert Comment

by:xtermie
ID: 41797493
script and suggestions work
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
LEFT JOIN Access Query 5 56
transposing cells in one go using VBA or a formula 7 53
Excel VBA - Public declaration of variables 3 45
Regarding Notepad++ 4 33
It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…

943 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

6 Experts available now in Live!

Get 1:1 Help Now