Outlook and Word Editor Command Bar Visibility

G

Guest

OK, so I have created an addin using VB6 that adds a command bar to Outlook
(2K+). When word is the editor, I have handled the CustomizationContext,
deleteing command bar manually, and ignoring a button click if done on a word
document.

BUT, I have one final issue I have been unable to resolve. When I have a
word document open and I open a new email then the word document displays the
command bar (as expected), however, the email does not. On the email I must
click on View/Toolbars/MyCmdBar to see it.

On the other hand if I have an email open, then I open a word document the
email displays the command bar and the word document does not (it is
available from View/Toolbars).

I would be ecstatic if I could figure out how to get the command bar to
always display on the email and never display on the word document. I would
be happy if I can get the command bar to always display on the email. Any
thoughts on how to do this?
 
K

Ken Slovak - [MVP - Outlook]

If you are handling NewInspector then for Outlook 2002 and 2003 you should
be able to add your buttons just as you would with the Outlook editor. To
prevent the buttons from showing up in a Word doc window what I do is
instantiate a Word application object WithEvents from
Inspector.WordEditor.Application. I then handle the WindowActivate event:

Private Sub oWord_WindowActivate(ByVal Doc As Word.Document, ByVal Wn As
Word.Window)

In that procedure I check for Wn.EnvelopeVisible. If true it's a WordMail
item, if false a normal Word document.
 
G

Guest

Ken, I am getting the command bar in Outlook with word as the editor. The
command bar also shows up in any word documents that are open at the time I
open an email or if I open a word document and and email is already open.

The issue has to do with how the command bar is displayed (window vs put on
the View / Toolbars menu) and in which application (word doc or email). I
need it to always display on the email window and prefer it never displays on
the word window.

Currently the following occurs:
1) No Word doc open, then open email, CB displays in email window
2) Word doc open, then open email, CB displays in word window & email menu
3) Email open, then open word doc, CB displays in email window & word menu

Scenario 2 is the problem.

I can see that if I trap the WindowActivate event I can determine if I am in
a word doc or email and possibly hide the command bar if I am in a word doc
(I am not sure if the window activate event actually fires in this situation
since it does not become the active window on the desktop). However, that
does not help to display the command bar in the email window.

I have attached snippets from my NewInspector and Add Command Bar routines

Thanks in advance.

Private Sub m_olInspectors_NewInspector(ByVal Inspector As Outlook.Inspector)

370 Dim i As Integer

'if its a mail item or appointment item then add the conference
buttons
380 If Inspector.CurrentItem.Class = olMail _
Or Inspector.CurrentItem.Class = olAppointment Then

'Don't add buttons to existing mail items (already sent)
390 If Inspector.CurrentItem.Class = olMail Then
400 If Inspector.CurrentItem.Sent = True Then
410 GoTo Exit_Sub
420 Else

660 End If

670 Call AddCmdBr(Inspector, "CollabCommandBar")

'Add Command Buttons

*************** etc.***************




Public Sub AddCmdBr(oInspctr As Outlook.Inspector, ByVal CBCntrlId As String)

10 Dim MyCmdBr As office.CommandBar
20 Dim CmdBrs As office.CommandBars


'add a command bar
'check to see if it exists because word editor doesn't delete
between uses
'(actually we now delete manually, but just in case)
30 Set CmdBrs = oInspctr.CommandBars
On Error Resume Next
40 Set MyCmdBr = CmdBrs(CBCntrlId)
On Error GoTo FailSafe_Error
50 If MyCmdBr Is Nothing Then
60 Set MyCmdBr = CmdBrs.Add(CBCntrlId, msoBarTop, False, True)
70 End If
80 With MyCmdBr
90 .Enabled = True
100 .Visible = True
110 End With
120 Set CmdBrs = Nothing
130 Set MyCmdBr = Nothing
End Sub
 
K

Ken Slovak - [MVP - Outlook]

If you get a handle to the Word window you can always check for
EnvelopeVisible. I use the window's activate function for that.

I also check in that event handler to see if my toolbars/buttons are there
in the Word doc and delete them if they are.

Another thing with Word is it has no understanding of declaring a toolbar or
button as Temporary. It persists even if you do that. So you need to add
your items in the CustomizationContext that you want and handle that
property to avoid the prompts to save changes.

I usually set CustomizationContext = ActiveDocument and before I add a
button I check for CustomizationContext.Saved. If True the document is
clean, if not it's false. If it was clean I set it True after adding my
buttons. Then in the Close event of the item and/or Inspector I explicitly
delete the buttons after checking CustomizationContext.Saved again. If
needed I set it True again to avoid the prompts to save changes.

If everything is properly created and destroyed at the correct times an
already open Word doc won't show any buttons you add to the WordMail doc.
Nor will any new docs opened after the WordMail doc is opened.
 
G

Guest

Ken, I will give this a try, probably not until next week, I'm booked this
week. This still does not get the command bar on the window of the email does
it?
 
K

Ken Slovak - [MVP - Outlook]

If you follow the information in the posts in this thread you should be
getting the button in emails and not in plain Word docs. That's how it works
in my addins with the methods I've described.
 
G

Guest

Thanks Ken, I'll try it.
--
John Svercek


Ken Slovak - said:
If you follow the information in the posts in this thread you should be
getting the button in emails and not in plain Word docs. That's how it works
in my addins with the methods I've described.
 
G

Guest

Ken, that works great, thanks a lot.

I do have one problem with wordmail and wondered if there is anything I can
do about it. That is, when I click the button the commandbars move around.
When the email loads it has my command bar just above the edit window. When I
click on a button on my bar it moves to above the format bar. The next click
moves the format bar to the right. Then everything stays in this
configuration.

I have not seen any way to control the location of the bar (other than top,
right, etc.) Any suggestions?
 
K

Ken Slovak - [MVP - Outlook]

I've never seen that problem. I always add my buttons to the Standard menu
for WordMail, even if for the Outlook editor I use my own custom toolbar. I
found too many problems otherwise as to where things were located, it could
be related to that. See if using Standard helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top