Can't add information to ppt2k7's footer,but it can work for ppt2k

T

Tonny

Hi, Guy.

I can add text to ppt2k3's footer. but it can't work on ppt2k7. every times
there is exception occured when i try to get text from footer on PPT2k7. but
it works well on PPT2k3. The source code as below:


bool bRet = false;
CComVariant var;
HRESULT hr = AutoWrap(DISPATCH_PROPERTYGET,&var,pDoc,L"Slides",0);
if(FAILED(hr) || var.pdispVal == NULL) return false;

IDispatch* pSlides=var.pdispVal;
pSlides->AddRef();
var.ClearToZero();
hr = AutoWrap(DISPATCH_PROPERTYGET,&var,pSlides,L"Count",0);
if(FAILED(hr) || var.llVal < 1)
{
pSlides->Release();
return false;
}

long lCount = var.llVal;
for(int i=0;i< lCount;i++)
{
hr= AutoWrap(DISPATCH_METHOD,&var,pSlides,L"Item",1,CComVariant(i+1));
if(FAILED(hr) || var.pdispVal == NULL) continue;

IDispatch* pSlide = var.pdispVal;
pSlide->AddRef();
var.ClearToZero();
hr = AutoWrap(DISPATCH_PROPERTYGET,&var,pSlide,L"HeadersFooters",0);
if(FAILED(hr) || var.pdispVal == NULL)
{
pSlide->Release();
continue;
}

IDispatch* pHFers= var.pdispVal;
pHFers->AddRef();
var.ClearToZero();
hr= AutoWrap(DISPATCH_PROPERTYGET,&var,pHFers,L"Footer",0);
if(SUCCEEDED(hr) && var.pdispVal != NULL)
{
IDispatch* pFooter = var.pdispVal;
pFooter->AddRef();
var.Clear();
// here there is exception occured when test it under ppt2k7.
hr = AutoWrap(DISPATCH_PROPERTYGET,&var,pFooter,L"Text",0);
if(SUCCEEDED(hr) && var.bstrVal != NULL)
{
std::wstring strValue(var.bstrVal);
var.Clear();
hr =
AutoWrap(DISPATCH_PROPERTYPUT,NULL,pFooter,L"Text",1,CComVariant(L"ssssssssss"));
if(SUCCEEDED(hr))
{
OutputDebugStringW(L"Okay............");
}
}
pFooter->Release();
}
pHFers->Release();
pSlide->Release();
}
pSlides->Release();


who can help for this issue?
 

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