Outlook blocks Word add-in :-(

F

Flemming Dahl

Hi all

Help is very much needed here:

I have created a word.dot file and placed it in Words Startup folder. When I
open Word the add-in reads some files, adds a new menuitem in word, and it
all works fine.

When it goes very bad:
- Start my pc
- Open Outlook2003 (using Word as email editor)
I can now see that a WINWORD.EXE session is opened on the pc, and that my
add-in is opened as well
- Open Word and nothing happens

It seems like Outlook opens my Word Add-in with out running the AutoExec and
AutoOpen...
and when I open Word it seems like Word says - oh the add-in file is already
opened by Word (the Outlook session) so Word does not run the AutoExec and
AutoOpen.


I don't my amount of spend time here - PLEASE help me get a solution here or
to report the posible "bug" to Microsoft.

Thanks
Flemming, Denmark

Posted both in microsoft.public.outlook.program_addins and
microsoft.public.word.vba.addins
 
D

Doug Robbins - Word MVP

It's a problem that we all face. The only way around it is to start/have
your users start Word FIRST.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
F

Flemming Dahl

Thank you for your reply Doug.

I had hoped for a better solution than "It's a bug in MS Office".

Do you know if it is reportet to Microsoft? or where to do so?

Thanks,
Flemming
 
D

Doug Robbins - Word MVP

Rather than being a bug, I believe that it is "by design", related to
security issues - Damn Virus Kiddies.

See the Knowledge Base Article at
http://support.microsoft.com/kb/286310/en-us

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
F

Flemming Dahl

You might be right - and yes - Damn Virus Kiddies.

Couldn't I make a add-in for outlook to start Adds a menuitem to the hidden
Word session, so that when word is started the menuitem can be found, at the
word add-in will provide the codebehind ?

..... any comments on that idea?
 
D

Doug Robbins - Word MVP

I suggest that you ask that question in an Outlook newsgroup.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Jonathan West

A sDoug as said, this is annoying but the way Word & Outlook work together.
If you are using Word as the email editor for outlook, then you cannot
assume that the AutoExec macro in a Word Add-in will fire.

Once you accept this as expected behavior, then the nature of the necessary
workaround is fairly straightforward. If your add-in has any user interface
items, then any macros triggered by them must first check to see if AutoExec
has been run (you can have it set a public Boolean variable when AutoExec
has finished), and run it immediately if it has not been run.
 
F

Flemming Dahl

Hi Jonathan

Thanks for your participation on this issue - and I see your point - but...

AutoExec fires a macro that adds a new menuitem next right next to the
"Help" menu item in Word.

When AutoExec have not been fired the menuitem have not been created... =>
nothing to press => no way to check a boolean.


Regards,
Flemming
 
J

Jonathan West

Flemming Dahl said:
Hi Jonathan

Thanks for your participation on this issue - and I see your point -
but...

AutoExec fires a macro that adds a new menuitem next right next to the
"Help" menu item in Word.

When AutoExec have not been fired the menuitem have not been created... =>
nothing to press => no way to check a boolean.


Oh, I've had a similar problem - a dynamic menu that needed to be built on
loading the add-in. There's a workaround for that. Place an ordinary
commandbarbutton on the menu. Set its ActionControl property to a macro that
replaces the button with the menu you want and then performs the Execute
method on the menu to drop it down. The user will have no idea that what he
has just clicked was originally a button that has disappeared and turned
into a menu.
 
K

Ken Slovak - [MVP - Outlook]

If it's a WordMail item (Window.EnvelopeVisible = True) then you would get
an Outlook NewInspector event from the Inspectors collection each time a new
email was opened. Using that event you can check for Inspector.IsWordMail =
True to verify the item is using WordMail. Then you can add your button to
whatever CustomizationContext you choose.
 
F

Flemming Dahl

Hi Ken

I can not be sure that the user will write a mail before opening Word, but I
can use the (Window.EnvelopeVisible = True) to ensure that my menu do not
work if it's a WordMail item.

Thanks
Flemming
 
F

Flemming Dahl

Hi Jonathan

Thanks A LOT - I belive this solution will work-a-round the Outlook issue of
MS Office (sorry Ken)

Thanks
Flemming
 
J

Jim

Jonathan said:
A sDoug as said, this is annoying but the way Word & Outlook work together.
If you are using Word as the email editor for outlook, then you cannot
assume that the AutoExec macro in a Word Add-in will fire.

Once you accept this as expected behavior, then the nature of the necessary
workaround is fairly straightforward. If your add-in has any user interface
items, then any macros triggered by them must first check to see if AutoExec
has been run (you can have it set a public Boolean variable when AutoExec
has finished), and run it immediately if it has not been run.
Are you still having issues, I can show you my code which was recommend
by Ken that will remove the commandvar in outlook but re-add it in Word.
Rog
 
J

Jonathan West

Jim said:
Are you still having issues, I can show you my code which was recommend by
Ken that will remove the commandvar in outlook but re-add it in Word.
Rog

I have a workaround that works for me, but I'm always interested in learning
of new or alternative approaches that might work even better. By all means
post the code!
 
F

Flemming Dahl

Thanks - Ken have given me links to his code.


Jim said:
Are you still having issues, I can show you my code which was recommend by
Ken that will remove the commandvar in outlook but re-add it in Word.
Rog
 
F

Flemming Dahl

Hi Jonathan

What am I doing wrong here...

When I want to delete CommandBarButton my code fails like this:
Run-time error '-214746729(80004005)':
Method 'Delete' of object '_CommandBartButton' failed

It seems like the CommandBarButton is active and can't be deleted...

How do you make it work?

Like this???
cbbJWest.Visible = False
ThisDocument.Saved = True

or how???


This is my code:

Private mcbMenu As CommandBar
Private Const msMY_MENU_NAME As String = "&SuperItWorks"

Public Sub JWestMenuItem()
Dim cbbJWest As CommandBarButton

Set mcbMenu = CommandBars.ActiveMenuBar
Set cbbJWest= mcbMenu.Controls(Replace(msMY_MENU_NAME, "&", ""))
'mcbMenu.Controls(mcbMenu.Controls(cbbJWest.Caption).Index - 1).SetFocus
cbbJWest.Delete

AutoExec

' CleanUp
Set cbbJWest= Nothing
Set mcbMenu = Nothing
End Sub
 
K

Ken Slovak - [MVP - Outlook]

At least with Outlook using WordMail, some properties and methods of a
button object aren't usable even though the button works and returns some
properties and fires the Click event.

What has worked for me in those cases (.Delete, .PasteFace, etc.) is to
reinstantiate the button using FindControl as a new, locally declared button
object within my cleanup procedure and calling .Delete on that locally
declared button object.
 
F

Flemming Dahl

Hi Ken

I have made lots of add-ins to both Word and Excel - never to Outlook, since
my company have been using Lotus Notes until now.

If I can solve it within Word I would prefer so - there is also the
installation on 6000 pc world wide to take in consideration before changing
anything that's working.

So my decision for now is - make it within Word.

I have added the following code into my AutoExec

Dim cbbTempButton As CommandBarButton

Set mcbMenu = CommandBars.ActiveMenuBar
Set cbbTempButton = mcbMenu.Controls(Replace(msMY_MENU_NAME, "&", ""))
With cbbTempButton
.Visible = False
.Caption = "SO_Hidden"
End With
ThisDocument.Saved = True

I have made another sub that is called by my "temp" button, and that sub
calles the AutoExec

This have only one disadvantage - first time the user opens Word he/she have
to press the menuitem twice which could be 6000 clicks world wide. If
Outlook stays open the rest of the day, then Word will also be open...
giving no more extra clicks - if not there could be more extra clicks.
This part I don't like.

Cheers,
Flemming
 
F

Flemming Dahl

That's the right answer Jonathan... cause the CommandBarButton can not be
deleted as I see it.

Thanks for your help - I got a good solution

Happy new year
Flemming - MVP wannabe
 

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