Re: Commandbars and ReadingView



Hi =?Utf-8?B?UGV0ZXIgS2FybHN0csO2bQ==?=,

I have developed a COM-Addin for Word in which a commandbar is created.

Everything works fine but now I have detected a problem.

If I open a document which is attached to a mail, Word opens the document in
ReadingView-mode. In that view my commanbar is created and alright.
But when I click Close to get to ordinary view of the document, the commandbar
is disabled.
No event is triggered (as far as I can see) when the close-button is used.
It's still in the list of toolbars but the user has to re-enable it.

Is it disabled, or is it just closed (.Visible = False)? Those are two very
different things, and I don't know how a user would re-enable a disabled
commandbar. OTOH, Word making it not visible is expected behavior.

Apparently, no events are fired when this ReadingMode is changed. I have tracked
down which commands Word uses for its toolbar buttons. If you were working with
VBA, then you could intercept the commands using procedures with the command
names, like this:

Sub ReadingMode()
Dim ToggleLayout As Boolean
ToggleLayout = ActiveDocument.ActiveWindow.View.ReadingLayout
ActiveDocument.ActiveWindow.View.ReadingLayout = Not ToggleLayout
CommandBars("My toolbar").Visible = True
End Sub

Sub CloseReadingMode()
Dim ToggleLayout As Boolean
ToggleLayout = ActiveDocument.ActiveWindow.View.ReadingLayout
ActiveDocument.ActiveWindow.View.ReadingLayout = Not ToggleLayout
CommandBars("My toolbar").Visible = True
End Sub

This won't work for a COM Add-in. However, you could create your own buttons
- that look just like Word's built-in ones, substitute them for Word's on the
Standard and Reading Layout commandbars, and have them do something similar to
the above.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

.