Compiler Error: Does not like Outlook.CommandBarControls.CommandBarControlPtr.Add

S

Shawn

I have a sample program below that I'm trying to convert to the newer mso.tlh (the code has not been updated for years). So, I had to add all of the "Outlook::" and "Office::" since the old tlh did not have the namespace defined in the tlh file.

Down on the bottom of this code that I have extracted, I keep getting the compiler error that it does not how I'm trying to use "Add". I have tried various parameters with no success. What is wrong with it before I burn my hair off my head. :/


Outlook::_Explorer *pExp;
Office::_CommandBars *pCBs;
Office::_CommandBarButton *pBtn;
Office::CommandBar *pOurBar;
Office::CommandBarControls *pApplicationCommandBar;
long buttonpos;
HRESULT hResult;
string toolbar_name;

buttonpos = 1;

toolbar_name = "Application";

if (m_pOutlookApp == NULL) {
return S_FALSE;
}

try {
hResult = m_pOutlookApp->ActiveExplorer(&pExp);
} catch (_com_error) {
debugoutput("[%s:%d] Exception when trying to get active explorer\n", __FILE__, __LINE__);
}

if (pExp == NULL) {
debugoutput("[%s:%d] Could not get a active explorer\n", __FILE__, __LINE__);
return S_FALSE;
}

try {
hResult = pExp->get_CommandBars(&pCBs);
} catch (_com_error) {
debugoutput("[%s:%d] Exception when trying to get pointer to command bar\n", __FILE__, __LINE__);
}

if (pCBs == NULL) {
debugoutput("[%s:%d] Cannot load command bar.\n", __FILE__, __LINE__);
return S_FALSE;
}

try {
pOurBar = pCBs->GetItem(toolbar_name.c_str());
pOurBar->Delete();
} catch (_com_error) {
}

m_pApplicationCmdBar = pCBs->Add( toolbar_name.c_str(),
_variant_t((long)Office::msoBarTop),
vtMissing,
_variant_t(VARIANT_TRUE, VT_BOOL));
m_pApplicationCmdBar->Protection = Office::msoBarNoCustomize;

pApplicationCommandBar = m_pApplicationCmdBar->Controls;

// Add a button

Compiler barfs on the following "Add"...
pBtn = pApplicationCommandBar->Add( _variant_t((long) Office::msoControlButton),
vtMissing,
vtMissing,
_variant_t(buttonpos++),
_variant_t(VARIANT_TRUE, VT_BOOL));

Complier error below is generated for the "Add" above... why?!
error C2679: binary '=' : no operator defined which takes a right-hand operand of type
'class _com_ptr_t
<
class _com_IIID
<
struct Office::CommandBarControl,&struct __s_GUID _GUID_000c0308_0000_0000_c000_000000000046
(or there is no acceptable conversion)
 
S

Shawn

Nobody has a clue to help me out? Am I'm leaving something out to help me? Do I have a bad tlh/tli files? Where can I get the latest tlh/tli files to make sure that I have the correct version?.
Submitted using http://www.outlookforums.com
 

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