Discussion:
n Word
(too old to reply)
David
2006-03-04 10:20:13 UTC
Permalink
Hello there.
I have a COM addin (ATL7, C++) for MS Word. My GUI is a commandbar with
some buttons and combo boxes on it. I'm, adding CommandBar object to Word
CommandBars collection - usual way. I'm setting folowing properties :

CComVariant vtName(_T("MY_COMMANDBAR_NAME"));
CComVariant vtPos(msoBarLeft|msoBarTop);
CComVariant vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
CComVariant vtTemp(VARIANT_TRUE); // is temporary
m_OCmdBar = m_OCmdBars ->Add(vtName,vtPos, vtEmpty, vtTemp);
m_OCmdBar->get_Protection(&m_barProtect);
m_OCmdBar->Protection = msoBarNoCustomize;
m_OCmdBar->put_NameLocal(_bstr_t("My Commad Bar"));
m_OCmdBar->put_Visible(VARIANT_TRUE);

Eevrything works fine: command bar is displayed and operational. The problem
begins with Outlook; if Word is a default email editor in Outlook I have
hundreds of
problems operating my addin (this is diffrernt story I can write a
book about this mess), therefore I decide to disable and do not show my
adddin toolbar while documnet container is an Outlook email message.
I'm just setting these props :
m_OCmdBar->put_Visible(VARIANT_FALSE);
m_OCmdBar->put_Enabled(VARIANT_FALSE);

Im doing this each time while handling OnDocumentChange event. This works
fine in Outlook, addin bar "disappears" in message window.
Each time Im checking if currrent document is not email Im setting these
properties back :
m_OCmdBar->put_Visible(VARIANT_TRUE);
m_OCmdBar->put_Enabled(VARIANT_TRUE);

Problem happens ONLY when using Outlook BFFORE regular Word dcoumnet
is being opened.
This code doesnot work properly if Outlook hosts Word doc.
When Im opening regular Word document CommandBar does not appear in Word
window, despite Visiible = true code execution !!! , Im checking HRESULT, try
, catch , nothing fails! However, It is possible to rightclick on toolbars
and select my CommandBar and display it , BUT I HAVE TO DO this from my code,
user cannot
search for the command bar each time it disappaears.
If I open Word BEFORE, and then use Outlook evrything works fine
CommandBar is visible /invisible as it should be according to my code.
I would like to stress in all cases OnDocumentChange event is fired and my
code is being executed without any error.
Pleas help!!! What can I do with Outlook? Any workaround ?
Hope I was clear enough describing this problem, thanks, David
Charles Kenyon
2006-03-04 13:28:29 UTC
Permalink
I don't have an answer, but do note a separate potential problem with your
code. It will act almost like a virus and annoy your users. It will make
changes to normal.dot because you do not set a customization context other
than normal.dot. Problems with such Add-Ins come up daily in these
newsgroups.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by David
Hello there.
I have a COM addin (ATL7, C++) for MS Word. My GUI is a commandbar with
some buttons and combo boxes on it. I'm, adding CommandBar object to Word
CComVariant vtName(_T("MY_COMMANDBAR_NAME"));
CComVariant vtPos(msoBarLeft|msoBarTop);
CComVariant vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
CComVariant vtTemp(VARIANT_TRUE); // is temporary
m_OCmdBar = m_OCmdBars ->Add(vtName,vtPos, vtEmpty, vtTemp);
m_OCmdBar->get_Protection(&m_barProtect);
m_OCmdBar->Protection = msoBarNoCustomize;
m_OCmdBar->put_NameLocal(_bstr_t("My Commad Bar"));
m_OCmdBar->put_Visible(VARIANT_TRUE);
Eevrything works fine: command bar is displayed and operational. The problem
begins with Outlook; if Word is a default email editor in Outlook I have
hundreds of
problems operating my addin (this is diffrernt story I can write a
book about this mess), therefore I decide to disable and do not show my
adddin toolbar while documnet container is an Outlook email message.
m_OCmdBar->put_Visible(VARIANT_FALSE);
m_OCmdBar->put_Enabled(VARIANT_FALSE);
Im doing this each time while handling OnDocumentChange event. This works
fine in Outlook, addin bar "disappears" in message window.
Each time Im checking if currrent document is not email Im setting these
m_OCmdBar->put_Visible(VARIANT_TRUE);
m_OCmdBar->put_Enabled(VARIANT_TRUE);
Problem happens ONLY when using Outlook BFFORE regular Word dcoumnet
is being opened.
This code doesnot work properly if Outlook hosts Word doc.
When Im opening regular Word document CommandBar does not appear in Word
window, despite Visiible = true code execution !!! , Im checking HRESULT, try
, catch , nothing fails! However, It is possible to rightclick on toolbars
and select my CommandBar and display it , BUT I HAVE TO DO this from my code,
user cannot
search for the command bar each time it disappaears.
If I open Word BEFORE, and then use Outlook evrything works fine
CommandBar is visible /invisible as it should be according to my code.
I would like to stress in all cases OnDocumentChange event is fired and my
code is being executed without any error.
Pleas help!!! What can I do with Outlook? Any workaround ?
Hope I was clear enough describing this problem, thanks, David
Jezebel
2006-03-04 20:39:57 UTC
Permalink
I agree. An application that screwed around with my system like this would
get VERY short shrift.
Post by Charles Kenyon
I don't have an answer, but do note a separate potential problem with your
code. It will act almost like a virus and annoy your users. It will make
changes to normal.dot because you do not set a customization context other
than normal.dot. Problems with such Add-Ins come up daily in these
newsgroups.
--
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by David
Hello there.
I have a COM addin (ATL7, C++) for MS Word. My GUI is a commandbar with
some buttons and combo boxes on it. I'm, adding CommandBar object to Word
CComVariant vtName(_T("MY_COMMANDBAR_NAME"));
CComVariant vtPos(msoBarLeft|msoBarTop);
CComVariant vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
CComVariant vtTemp(VARIANT_TRUE); // is temporary
m_OCmdBar = m_OCmdBars ->Add(vtName,vtPos, vtEmpty, vtTemp);
m_OCmdBar->get_Protection(&m_barProtect);
m_OCmdBar->Protection = msoBarNoCustomize;
m_OCmdBar->put_NameLocal(_bstr_t("My Commad Bar"));
m_OCmdBar->put_Visible(VARIANT_TRUE);
Eevrything works fine: command bar is displayed and operational. The problem
begins with Outlook; if Word is a default email editor in Outlook I have
hundreds of
problems operating my addin (this is diffrernt story I can write a
book about this mess), therefore I decide to disable and do not show my
adddin toolbar while documnet container is an Outlook email message.
m_OCmdBar->put_Visible(VARIANT_FALSE);
m_OCmdBar->put_Enabled(VARIANT_FALSE);
Im doing this each time while handling OnDocumentChange event. This works
fine in Outlook, addin bar "disappears" in message window.
Each time Im checking if currrent document is not email Im setting these
m_OCmdBar->put_Visible(VARIANT_TRUE);
m_OCmdBar->put_Enabled(VARIANT_TRUE);
Problem happens ONLY when using Outlook BFFORE regular Word dcoumnet
is being opened.
This code doesnot work properly if Outlook hosts Word doc.
When Im opening regular Word document CommandBar does not appear in Word
window, despite Visiible = true code execution !!! , Im checking HRESULT, try
, catch , nothing fails! However, It is possible to rightclick on toolbars
and select my CommandBar and display it , BUT I HAVE TO DO this from my code,
user cannot
search for the command bar each time it disappaears.
If I open Word BEFORE, and then use Outlook evrything works fine
CommandBar is visible /invisible as it should be according to my code.
I would like to stress in all cases OnDocumentChange event is fired and my
code is being executed without any error.
Pleas help!!! What can I do with Outlook? Any workaround ?
Hope I was clear enough describing this problem, thanks, David
David
2006-03-05 14:45:27 UTC
Permalink
Please excuse my ignorance, but I do not understand your reply. Im not MS
Office/VBA programmer, may be I dont know a lot of things, Im relying on poor
MSDN documewntation which is completely VB oriented - Im using VC++.
Im not touching normal.dot, I have only one COM dll which contains all
runtime code. And why Outlook srews EVERYTHIGN in MS Word functions while
hosting it ?
Thanks, David
Post by Charles Kenyon
I don't have an answer, but do note a separate potential problem with your
code. It will act almost like a virus and annoy your users. It will make
changes to normal.dot because you do not set a customization context other
than normal.dot. Problems with such Add-Ins come up daily in these
newsgroups.
--
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by David
Hello there.
I have a COM addin (ATL7, C++) for MS Word. My GUI is a commandbar with
some buttons and combo boxes on it. I'm, adding CommandBar object to Word
CComVariant vtName(_T("MY_COMMANDBAR_NAME"));
CComVariant vtPos(msoBarLeft|msoBarTop);
CComVariant vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
CComVariant vtTemp(VARIANT_TRUE); // is temporary
m_OCmdBar = m_OCmdBars ->Add(vtName,vtPos, vtEmpty, vtTemp);
m_OCmdBar->get_Protection(&m_barProtect);
m_OCmdBar->Protection = msoBarNoCustomize;
m_OCmdBar->put_NameLocal(_bstr_t("My Commad Bar"));
m_OCmdBar->put_Visible(VARIANT_TRUE);
Eevrything works fine: command bar is displayed and operational. The problem
begins with Outlook; if Word is a default email editor in Outlook I have
hundreds of
problems operating my addin (this is diffrernt story I can write a
book about this mess), therefore I decide to disable and do not show my
adddin toolbar while documnet container is an Outlook email message.
m_OCmdBar->put_Visible(VARIANT_FALSE);
m_OCmdBar->put_Enabled(VARIANT_FALSE);
Im doing this each time while handling OnDocumentChange event. This works
fine in Outlook, addin bar "disappears" in message window.
Each time Im checking if currrent document is not email Im setting these
m_OCmdBar->put_Visible(VARIANT_TRUE);
m_OCmdBar->put_Enabled(VARIANT_TRUE);
Problem happens ONLY when using Outlook BFFORE regular Word dcoumnet
is being opened.
This code doesnot work properly if Outlook hosts Word doc.
When Im opening regular Word document CommandBar does not appear in Word
window, despite Visiible = true code execution !!! , Im checking HRESULT, try
, catch , nothing fails! However, It is possible to rightclick on toolbars
and select my CommandBar and display it , BUT I HAVE TO DO this from my code,
user cannot
search for the command bar each time it disappaears.
If I open Word BEFORE, and then use Outlook evrything works fine
CommandBar is visible /invisible as it should be according to my code.
I would like to stress in all cases OnDocumentChange event is fired and my
code is being executed without any error.
Pleas help!!! What can I do with Outlook? Any workaround ?
Hope I was clear enough describing this problem, thanks, David
Charles Kenyon
2006-03-05 18:01:42 UTC
Permalink
Changes made to the user interface through code are stored in normal.dot, by
default. That is the default "customization context." This is a
semi-permanent change in the user interface, not always welcome, and always
unnecessary. A separate template can hold the same customizations without
the nastiness of altering the user's normal.dot. I would recommend that your
code create a template in the users startup folder and mark that as the
customization context for your code. Have your code load it as an Add-In
when created. Have your code check for the template's presence upon starting
and if it is present, you can skip a lot of your code (speeding up your
processes) because any interface modifications you make with your code
(toolbars, menus, keyboard shortcuts, AutoText) will be stored in the
template and automatically loaded upon startup of Word.

Have the customization context for any other or additional changes you make
set to your template. That way you don't make changes to the user's
normal.dot. (Otherwise, good coding would clean up or eliminate these
changes upon completion of its task. This is not easy to do. I don't know
that Adobe has figured it out yet!) This means any uninstall utility you run
should also delete your template.

You can have your code either save your template after you make changes
(setting the changes to be loaded the next time your user starts Word), or
mark your template's saved state to true. This way your user won't be
prompted about saving changes to your template when they attempt to quit
Word.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by David
Please excuse my ignorance, but I do not understand your reply. Im not
MS
Office/VBA programmer, may be I dont know a lot of things, Im relying on poor
MSDN documewntation which is completely VB oriented - Im using VC++.
Im not touching normal.dot, I have only one COM dll which contains all
runtime code. And why Outlook srews EVERYTHIGN in MS Word functions while
hosting it ?
Thanks, David
Post by Charles Kenyon
I don't have an answer, but do note a separate potential problem with your
code. It will act almost like a virus and annoy your users. It will make
changes to normal.dot because you do not set a customization context other
than normal.dot. Problems with such Add-Ins come up daily in these
newsgroups.
--
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by David
Hello there.
I have a COM addin (ATL7, C++) for MS Word. My GUI is a commandbar with
some buttons and combo boxes on it. I'm, adding CommandBar object to Word
CComVariant vtName(_T("MY_COMMANDBAR_NAME"));
CComVariant vtPos(msoBarLeft|msoBarTop);
CComVariant vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
CComVariant vtTemp(VARIANT_TRUE); // is temporary
m_OCmdBar = m_OCmdBars ->Add(vtName,vtPos, vtEmpty, vtTemp);
m_OCmdBar->get_Protection(&m_barProtect);
m_OCmdBar->Protection = msoBarNoCustomize;
m_OCmdBar->put_NameLocal(_bstr_t("My Commad Bar"));
m_OCmdBar->put_Visible(VARIANT_TRUE);
Eevrything works fine: command bar is displayed and operational. The problem
begins with Outlook; if Word is a default email editor in Outlook I have
hundreds of
problems operating my addin (this is diffrernt story I can write a
book about this mess), therefore I decide to disable and do not show my
adddin toolbar while documnet container is an Outlook email message.
m_OCmdBar->put_Visible(VARIANT_FALSE);
m_OCmdBar->put_Enabled(VARIANT_FALSE);
Im doing this each time while handling OnDocumentChange event. This works
fine in Outlook, addin bar "disappears" in message window.
Each time Im checking if currrent document is not email Im setting these
m_OCmdBar->put_Visible(VARIANT_TRUE);
m_OCmdBar->put_Enabled(VARIANT_TRUE);
Problem happens ONLY when using Outlook BFFORE regular Word dcoumnet
is being opened.
This code doesnot work properly if Outlook hosts Word doc.
When Im opening regular Word document CommandBar does not appear in Word
window, despite Visiible = true code execution !!! , Im checking
HRESULT,
try
, catch , nothing fails! However, It is possible to rightclick on toolbars
and select my CommandBar and display it , BUT I HAVE TO DO this from my code,
user cannot
search for the command bar each time it disappaears.
If I open Word BEFORE, and then use Outlook evrything works fine
CommandBar is visible /invisible as it should be according to my code.
I would like to stress in all cases OnDocumentChange event is fired and my
code is being executed without any error.
Pleas help!!! What can I do with Outlook? Any workaround ?
Hope I was clear enough describing this problem, thanks, David
Jezebel
2006-03-06 08:44:15 UTC
Permalink
Proclaiming your ignorance is laudable. (It's Socrates' main claim to fame,
at that.) But given your admitted ignorance, stay out of this area of
programming entirely. And I mean that in the nicest possible way.
Post by David
Please excuse my ignorance, but I do not understand your reply. Im not
MS
Office/VBA programmer, may be I dont know a lot of things, Im relying on poor
MSDN documewntation which is completely VB oriented - Im using VC++.
Im not touching normal.dot, I have only one COM dll which contains all
runtime code. And why Outlook srews EVERYTHIGN in MS Word functions while
hosting it ?
Thanks, David
Post by Charles Kenyon
I don't have an answer, but do note a separate potential problem with your
code. It will act almost like a virus and annoy your users. It will make
changes to normal.dot because you do not set a customization context other
than normal.dot. Problems with such Add-Ins come up daily in these
newsgroups.
--
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by David
Hello there.
I have a COM addin (ATL7, C++) for MS Word. My GUI is a commandbar with
some buttons and combo boxes on it. I'm, adding CommandBar object to Word
CComVariant vtName(_T("MY_COMMANDBAR_NAME"));
CComVariant vtPos(msoBarLeft|msoBarTop);
CComVariant vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
CComVariant vtTemp(VARIANT_TRUE); // is temporary
m_OCmdBar = m_OCmdBars ->Add(vtName,vtPos, vtEmpty, vtTemp);
m_OCmdBar->get_Protection(&m_barProtect);
m_OCmdBar->Protection = msoBarNoCustomize;
m_OCmdBar->put_NameLocal(_bstr_t("My Commad Bar"));
m_OCmdBar->put_Visible(VARIANT_TRUE);
Eevrything works fine: command bar is displayed and operational. The problem
begins with Outlook; if Word is a default email editor in Outlook I have
hundreds of
problems operating my addin (this is diffrernt story I can write a
book about this mess), therefore I decide to disable and do not show my
adddin toolbar while documnet container is an Outlook email message.
m_OCmdBar->put_Visible(VARIANT_FALSE);
m_OCmdBar->put_Enabled(VARIANT_FALSE);
Im doing this each time while handling OnDocumentChange event. This works
fine in Outlook, addin bar "disappears" in message window.
Each time Im checking if currrent document is not email Im setting these
m_OCmdBar->put_Visible(VARIANT_TRUE);
m_OCmdBar->put_Enabled(VARIANT_TRUE);
Problem happens ONLY when using Outlook BFFORE regular Word dcoumnet
is being opened.
This code doesnot work properly if Outlook hosts Word doc.
When Im opening regular Word document CommandBar does not appear in Word
window, despite Visiible = true code execution !!! , Im checking
HRESULT,
try
, catch , nothing fails! However, It is possible to rightclick on toolbars
and select my CommandBar and display it , BUT I HAVE TO DO this from my code,
user cannot
search for the command bar each time it disappaears.
If I open Word BEFORE, and then use Outlook evrything works fine
CommandBar is visible /invisible as it should be according to my code.
I would like to stress in all cases OnDocumentChange event is fired and my
code is being executed without any error.
Pleas help!!! What can I do with Outlook? Any workaround ?
Hope I was clear enough describing this problem, thanks, David
David
2006-03-06 16:05:29 UTC
Permalink
Well OK, thanks for very useful inputs. Specially explaining Outlook/Word
interaction.
Post by Jezebel
Proclaiming your ignorance is laudable. (It's Socrates' main claim to fame,
at that.) But given your admitted ignorance, stay out of this area of
programming entirely. And I mean that in the nicest possible way.
Post by David
Please excuse my ignorance, but I do not understand your reply. Im not
MS
Office/VBA programmer, may be I dont know a lot of things, Im relying on poor
MSDN documewntation which is completely VB oriented - Im using VC++.
Im not touching normal.dot, I have only one COM dll which contains all
runtime code. And why Outlook srews EVERYTHIGN in MS Word functions while
hosting it ?
Thanks, David
Post by Charles Kenyon
I don't have an answer, but do note a separate potential problem with your
code. It will act almost like a virus and annoy your users. It will make
changes to normal.dot because you do not set a customization context other
than normal.dot. Problems with such Add-Ins come up daily in these
newsgroups.
--
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by David
Hello there.
I have a COM addin (ATL7, C++) for MS Word. My GUI is a commandbar with
some buttons and combo boxes on it. I'm, adding CommandBar object to Word
CComVariant vtName(_T("MY_COMMANDBAR_NAME"));
CComVariant vtPos(msoBarLeft|msoBarTop);
CComVariant vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
CComVariant vtTemp(VARIANT_TRUE); // is temporary
m_OCmdBar = m_OCmdBars ->Add(vtName,vtPos, vtEmpty, vtTemp);
m_OCmdBar->get_Protection(&m_barProtect);
m_OCmdBar->Protection = msoBarNoCustomize;
m_OCmdBar->put_NameLocal(_bstr_t("My Commad Bar"));
m_OCmdBar->put_Visible(VARIANT_TRUE);
Eevrything works fine: command bar is displayed and operational. The problem
begins with Outlook; if Word is a default email editor in Outlook I have
hundreds of
problems operating my addin (this is diffrernt story I can write a
book about this mess), therefore I decide to disable and do not show my
adddin toolbar while documnet container is an Outlook email message.
m_OCmdBar->put_Visible(VARIANT_FALSE);
m_OCmdBar->put_Enabled(VARIANT_FALSE);
Im doing this each time while handling OnDocumentChange event. This works
fine in Outlook, addin bar "disappears" in message window.
Each time Im checking if currrent document is not email Im setting these
m_OCmdBar->put_Visible(VARIANT_TRUE);
m_OCmdBar->put_Enabled(VARIANT_TRUE);
Problem happens ONLY when using Outlook BFFORE regular Word dcoumnet
is being opened.
This code doesnot work properly if Outlook hosts Word doc.
When Im opening regular Word document CommandBar does not appear in Word
window, despite Visiible = true code execution !!! , Im checking
HRESULT,
try
, catch , nothing fails! However, It is possible to rightclick on toolbars
and select my CommandBar and display it , BUT I HAVE TO DO this from my code,
user cannot
search for the command bar each time it disappaears.
If I open Word BEFORE, and then use Outlook evrything works fine
CommandBar is visible /invisible as it should be according to my code.
I would like to stress in all cases OnDocumentChange event is fired and my
code is being executed without any error.
Pleas help!!! What can I do with Outlook? Any workaround ?
Hope I was clear enough describing this problem, thanks, David
Charles Kenyon
2006-03-06 16:57:16 UTC
Permalink
Sorry, but _my_ ignorance is showing here. All I know about the Word Outlook
interface is to not use Word as my Outlook email editor and that if I were
to try to merge Outlook contact data into Word, I would start from Outlook.

I suspect that if you put Outlook in your posting subject you might get more
knowledgeable answers. http://www.mvps.org/word/FindHelp/Posting.htm Jezebel
have given what help we could, but she may not know that much more about the
Outlook problems than do I. The problems we have pointed out are much more
important for you, though, even though your questions may not have been
answered.

Before you try programming Word, you need to learn it, comprehensively.
People can afford to waste a bit of their own time recording macros and
learning code, because in the long term, this can save them time. However,
if you are writing code for others to use, you are going to be wasting their
time and causing them trouble unless you know what you are doing. You will
end up making them angry; hopefully, their anger will be directed at you
rather than at using computers.

Please do not take this personally. I am sure you are a very good
programmer, but Word is an incredibly rich and complex environment in which
to be programming. In some ways it is like being a very good Boy Scout
plopped down in the middle of a dark powerless explosives factory in a war
zone. He's cold and it is dark. The Boy Scout knows how to light a fire but
doesn't know about the explosives ... The first question is whether a fire
is a good idea, but the Boy Scout doesn't know that this is the first
question because no one told him about the explosives. That is overly
dramatic, but the idea is that if you don't know the Word object model
before you start programming it for others, you have no idea what problems
your code could cause or what short cuts are already built-in. If you don't
do this, it should cost you and your supervisor your jobs! This is the sort
of situation where time spent learning will be repaid exponentially; code
written absent the learning will be a black hole that will suck up your time
and that of your users.

I pointed out a couple of problems I saw, in areas that I do know something
about, but I can't guess what other bombs you may be building and right now,
I'm not sure you know enough to know what questions to ask.

People here will be glad to share their experience with you and help you,
but they can't do your job for you.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by David
Well OK, thanks for very useful inputs. Specially explaining Outlook/Word
interaction.
Post by Jezebel
Proclaiming your ignorance is laudable. (It's Socrates' main claim to fame,
at that.) But given your admitted ignorance, stay out of this area of
programming entirely. And I mean that in the nicest possible way.
Post by David
Please excuse my ignorance, but I do not understand your reply. Im not
MS
Office/VBA programmer, may be I dont know a lot of things, Im relying
on
poor
MSDN documewntation which is completely VB oriented - Im using VC++.
Im not touching normal.dot, I have only one COM dll which contains all
runtime code. And why Outlook srews EVERYTHIGN in MS Word functions while
hosting it ?
Thanks, David
Post by Charles Kenyon
I don't have an answer, but do note a separate potential problem with your
code. It will act almost like a virus and annoy your users. It will make
changes to normal.dot because you do not set a customization context other
than normal.dot. Problems with such Add-Ins come up daily in these
newsgroups.
--
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by David
Hello there.
I have a COM addin (ATL7, C++) for MS Word. My GUI is a commandbar with
some buttons and combo boxes on it. I'm, adding CommandBar object to Word
CComVariant vtName(_T("MY_COMMANDBAR_NAME"));
CComVariant vtPos(msoBarLeft|msoBarTop);
CComVariant vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
CComVariant vtTemp(VARIANT_TRUE); // is temporary
m_OCmdBar = m_OCmdBars ->Add(vtName,vtPos, vtEmpty, vtTemp);
m_OCmdBar->get_Protection(&m_barProtect);
m_OCmdBar->Protection = msoBarNoCustomize;
m_OCmdBar->put_NameLocal(_bstr_t("My Commad Bar"));
m_OCmdBar->put_Visible(VARIANT_TRUE);
Eevrything works fine: command bar is displayed and operational. The problem
begins with Outlook; if Word is a default email editor in Outlook I have
hundreds of
problems operating my addin (this is diffrernt story I can write a
book about this mess), therefore I decide to disable and do not show my
adddin toolbar while documnet container is an Outlook email message.
m_OCmdBar->put_Visible(VARIANT_FALSE);
m_OCmdBar->put_Enabled(VARIANT_FALSE);
Im doing this each time while handling OnDocumentChange event. This works
fine in Outlook, addin bar "disappears" in message window.
Each time Im checking if currrent document is not email Im setting these
m_OCmdBar->put_Visible(VARIANT_TRUE);
m_OCmdBar->put_Enabled(VARIANT_TRUE);
Problem happens ONLY when using Outlook BFFORE regular Word dcoumnet
is being opened.
This code doesnot work properly if Outlook hosts Word doc.
When Im opening regular Word document CommandBar does not appear in Word
window, despite Visiible = true code execution !!! , Im checking
HRESULT,
try
, catch , nothing fails! However, It is possible to rightclick on toolbars
and select my CommandBar and display it , BUT I HAVE TO DO this from
my
code,
user cannot
search for the command bar each time it disappaears.
If I open Word BEFORE, and then use Outlook evrything works fine
CommandBar is visible /invisible as it should be according to my code.
I would like to stress in all cases OnDocumentChange event is fired
and
my
code is being executed without any error.
Pleas help!!! What can I do with Outlook? Any workaround ?
Hope I was clear enough describing this problem, thanks, David
David
2006-03-07 11:41:50 UTC
Permalink
This post might be inappropriate. Click to display it.
Charles Kenyon
2006-03-07 14:19:08 UTC
Permalink
David,
Post by David
Outlook hosting Word as email editor, at this point Word starts to behave in
very odd way. Some events are not fired as expected, Word loading process is
changed as it is hosted as Active Document in Outlook, Specially I have a
problem with OnDocumentBeforeClose event. If Word document is hosted in
Outlook message this event sometimes is fired without any user interaction
and second parameter
: OnDocumentBeforeClose(IDispatch * /*[in] Document* Doc*/ Doc
,VARIANT_BOOL
* CancelDefault) is set to VARAINT_TRUE , this have a very bad consequence to
my application. I'm giving here just a small example of vast range of
problems in Word/Outlook interaction. I tried to solve these problem however
there is almost no explanation about Outlook/Word operation, I tried MSDN,
Google, newsgroups etc, nothing really useful. I cannot afford spending weeks
to investigate this issues almost without any information. That's how I
get
to this ugly solution : to hide my CommandBar while working in email message
item and show it while working in "regular" Word document. Even this solution
works quite well besides the only case when Outlook message is opened before
any "regular" Word document - I won't repeat my previous explanation. Hope
I've told you that I have no experience in this area; my knowledge is
limited to advising individuals to avoid using Word as their email editor
because it causes problems. Please read the posting suggestions. With a
topic "n Word" you are not going to find people who know how Outlook and
Word interact reading your post. These newsgroups are very busy and the
people responding are volunteers, other users. They pick which topics to
read and respond to by looking at the subject headings.
http://www.mvps.org/word/FindHelp/Posting.htm

You need to cross-post in an Outlook programming newsgroup as well. Note,
cross-post, not multi-post. One message with both newsgroups in the header,
not the same post to both newsgroups. I don't know that this can be done
through the web interface.

Post specific code and error messages. One area or problem at a time.
Post by David
I had to create Word addin which actually performs some GDI operations in
the Word document, namely I'm drawing on Word DC; already here I'm violating
Word/Office Object model as I'm actually hacking and tweaking it - but this
is what I'm exactly have to do. Alongside with this I'm adding some shapes
and text in to Word document - all this works just fine. Moreover my addin is
multithreaded, which also somehow contradicts Word/VBA threading style. What
I'm trying to say is that I have quite unusual application - well life is not
easy.
AFAIK this is in no way unusual. VBA is intended and designed to let the
user or developer change or tweak the UI, to add shapes or text to a Word
document or the other things you are doing. Multi-threading is beyond my
experience but I doubt that it is stretching what is intended. But if you
learned Word, you would learn that it has built-in tools for adding shapes
or text such as AutoText. Instead, it seems that you are trying to recreate
these.
Post by David
Google, newsgroups etc, nothing really useful. I cannot afford spending weeks
to investigate this issues almost without any information. That's how I
get
I'm sorry that you don't have enough time. You have the same amount everyone
else has, though. It may be that you have not been given or alloted enough
time to do an adequate job on this project. The time of the volunteers on
these newsgroups is also valuable. Please let us help you by providing
specifics.

You've said that your application works fine so long as Outlook is not
involved. A simple thing to do may be to check whether Outlook is involved
and if it is, ask your user to switch it off. However, if you are changing
the UI and not specifying customization context, you are mucking around with
your user's normal.dot, you just don't know it. Your application is not
working fine even without Outlook. You are playing with explosives and have
been lucky so far. If nothing else, do read up on customization context.
This won't take that much time and in the long run will save you and your
users a lot of time.

I again recommend starting a new post, cross-posted, following the posting
guidelines, with a useful subject heading. I can't give you more assistance;
I doubt Jezebel cares to respond further. Given the length of this thread
and that no one with knowledge of the Word/Outlook interaction has
responded, providing more information in this thread is not likely to lead
to the help you need, and could get. Again, "n Word" just doesn't draw the
help you need.
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by David
Hello again, thank you for lengthy and imaginative post!
And lets drop this useless discussion who is good or bad programmer here, I
do respect and appreciate all the people who try to really HELP and not just
preach. I'm more OS low level engineer, mostly C/C++, COM etc, I do not have
a lot of VBA/MS Office programming experience.
It seems that my original post was not stated clear enough, I will try to be
more clear now.
I had to create Word addin which actually performs some GDI operations in
the Word document, namely I'm drawing on Word DC; already here I'm violating
Word/Office Object model as I'm actually hacking and tweaking it - but this
is what I'm exactly have to do. Alongside with this I'm adding some shapes
and text in to Word document - all this works just fine. Moreover my addin is
multithreaded, which also somehow contradicts Word/VBA threading style. What
I'm trying to say is that I have quite unusual application - well life is not
easy.
I also have GUI: CommandBar with some controls - and that worked fine, both
in Office XP ,2000 and 2003.
May be I lack some or a lot of knowledge in MS Office programming but I'm
working on very tight schedule and I succeeded to resolve almost all
problems. Anyway, everything works fine in Word, by the way I never had any
problem with Normal. dot template , never screwed it up to any user and I
have quite a lot of user actually working with may addin. I guess that your
suggestions redesigning "customization context" is correct. But lets leave
this issue for the moment.
The root of the problem is that I'm using Word objects events ( like
OnDocumentBeforeClose and OnWindowActivate etc) to get data from Word objects
as I have to perform some calculations. I don't know if there is any other
way to get notification from Word ( beside setting some hooks on Word windows
and system events) that user, for instance have switched between two Word
documents or use wants to save a document. So I tried to be more VB oriented
and get connected to theses events - and they work fine I got all events, I
got all data and Word behaves as I would expect. The problem starts with
Outlook hosting Word as email editor, at this point Word starts to behave in
very odd way. Some events are not fired as expected, Word loading process is
changed as it is hosted as Active Document in Outlook, Specially I have a
problem with OnDocumentBeforeClose event. If Word document is hosted in
Outlook message this event sometimes is fired without any user interaction
and second parameter
: OnDocumentBeforeClose(IDispatch * /*[in] Document* Doc*/ Doc
,VARIANT_BOOL
* CancelDefault) is set to VARAINT_TRUE , this have a very bad consequence to
my application. I'm giving here just a small example of vast range of
problems in Word/Outlook interaction. I tried to solve these problem however
there is almost no explanation about Outlook/Word operation, I tried MSDN,
Google, newsgroups etc, nothing really useful. I cannot afford spending weeks
to investigate this issues almost without any information. That's how I
get
to this ugly solution : to hide my CommandBar while working in email message
item and show it while working in "regular" Word document. Even this solution
works quite well besides the only case when Outlook message is opened before
any "regular" Word document - I won't repeat my previous explanation. Hope
now you have more complete picture and will have more input regarding my
problem or you can direct me to correct people or forums. Thank you again,
David.
Post by Charles Kenyon
Sorry, but _my_ ignorance is showing here. All I know about the Word Outlook
interface is to not use Word as my Outlook email editor and that if I were
to try to merge Outlook contact data into Word, I would start from Outlook.
I suspect that if you put Outlook in your posting subject you might get more
knowledgeable answers. http://www.mvps.org/word/FindHelp/Posting.htm Jezebel
have given what help we could, but she may not know that much more about the
Outlook problems than do I. The problems we have pointed out are much more
important for you, though, even though your questions may not have been
answered.
Before you try programming Word, you need to learn it, comprehensively.
People can afford to waste a bit of their own time recording macros and
learning code, because in the long term, this can save them time. However,
if you are writing code for others to use, you are going to be wasting their
time and causing them trouble unless you know what you are doing. You will
end up making them angry; hopefully, their anger will be directed at you
rather than at using computers.
Please do not take this personally. I am sure you are a very good
programmer, but Word is an incredibly rich and complex environment in which
to be programming. In some ways it is like being a very good Boy Scout
plopped down in the middle of a dark powerless explosives factory in a war
zone. He's cold and it is dark. The Boy Scout knows how to light a fire but
doesn't know about the explosives ... The first question is whether a fire
is a good idea, but the Boy Scout doesn't know that this is the first
question because no one told him about the explosives. That is overly
dramatic, but the idea is that if you don't know the Word object model
before you start programming it for others, you have no idea what problems
your code could cause or what short cuts are already built-in. If you don't
do this, it should cost you and your supervisor your jobs! This is the sort
of situation where time spent learning will be repaid exponentially; code
written absent the learning will be a black hole that will suck up your time
and that of your users.
I pointed out a couple of problems I saw, in areas that I do know something
about, but I can't guess what other bombs you may be building and right now,
I'm not sure you know enough to know what questions to ask.
People here will be glad to share their experience with you and help you,
but they can't do your job for you.
--
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by David
Well OK, thanks for very useful inputs. Specially explaining Outlook/Word
interaction.
Post by Jezebel
Proclaiming your ignorance is laudable. (It's Socrates' main claim to fame,
at that.) But given your admitted ignorance, stay out of this area of
programming entirely. And I mean that in the nicest possible way.
Post by David
Please excuse my ignorance, but I do not understand your reply. Im not
MS
Office/VBA programmer, may be I dont know a lot of things, Im relying
on
poor
MSDN documewntation which is completely VB oriented - Im using VC++.
Im not touching normal.dot, I have only one COM dll which contains all
runtime code. And why Outlook srews EVERYTHIGN in MS Word functions while
hosting it ?
Thanks, David
Post by Charles Kenyon
I don't have an answer, but do note a separate potential problem
with
your
code. It will act almost like a virus and annoy your users. It will make
changes to normal.dot because you do not set a customization
context
other
than normal.dot. Problems with such Add-Ins come up daily in these
newsgroups.
--
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by David
Hello there.
I have a COM addin (ATL7, C++) for MS Word. My GUI is a
commandbar
with
some buttons and combo boxes on it. I'm, adding CommandBar object
to
Word
CommandBars collection - usual way. I'm setting folowing
properties
CComVariant vtName(_T("MY_COMMANDBAR_NAME"));
CComVariant vtPos(msoBarLeft|msoBarTop);
CComVariant vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
CComVariant vtTemp(VARIANT_TRUE); // is temporary
m_OCmdBar = m_OCmdBars ->Add(vtName,vtPos, vtEmpty, vtTemp);
m_OCmdBar->get_Protection(&m_barProtect);
m_OCmdBar->Protection = msoBarNoCustomize;
m_OCmdBar->put_NameLocal(_bstr_t("My Commad Bar"));
m_OCmdBar->put_Visible(VARIANT_TRUE);
Eevrything works fine: command bar is displayed and operational. The
problem
begins with Outlook; if Word is a default email editor in Outlook
I
have
hundreds of
problems operating my addin (this is diffrernt story I can write a
book about this mess), therefore I decide to disable and do not
show
my
adddin toolbar while documnet container is an Outlook email message.
m_OCmdBar->put_Visible(VARIANT_FALSE);
m_OCmdBar->put_Enabled(VARIANT_FALSE);
Im doing this each time while handling OnDocumentChange event.
This
works
fine in Outlook, addin bar "disappears" in message window.
Each time Im checking if currrent document is not email Im
setting
these
m_OCmdBar->put_Visible(VARIANT_TRUE);
m_OCmdBar->put_Enabled(VARIANT_TRUE);
Problem happens ONLY when using Outlook BFFORE regular Word dcoumnet
is being opened.
This code doesnot work properly if Outlook hosts Word doc.
When Im opening regular Word document CommandBar does not appear
in
Word
window, despite Visiible = true code execution !!! , Im checking
HRESULT,
try
, catch , nothing fails! However, It is possible to rightclick
on
toolbars
and select my CommandBar and display it , BUT I HAVE TO DO this from
my
code,
user cannot
search for the command bar each time it disappaears.
If I open Word BEFORE, and then use Outlook evrything works fine
CommandBar is visible /invisible as it should be according to my code.
I would like to stress in all cases OnDocumentChange event is fired
and
my
code is being executed without any error.
Pleas help!!! What can I do with Outlook? Any workaround ?
Hope I was clear enough describing this problem, thanks, David
Loading...