I don't know how to user VBstr

Y

YOUNGHEE

This source don't work correctly.
I Don't know what problem is.

long numOfShape;
char *name;

app.Documents(docs);
docs.Item(VVariant(1L), doc);
doc.Pages(pages);
pages.Item(VVariant(1L), page);
page.Shapes(shapes);

shapes.Count(&numOfShape);

for(i=1; i<numOfShape; i++)
{
name = NULL;
shapes.Item(VVariant(i), shape);
shape.getName(VBstr(name));
AfxMessageBox(name);
SysFreeString(bstr);
}
 
S

Scott Metzger

YOUNGHEE said:
This source don't work correctly.
I Don't know what problem is.

long numOfShape;
char *name;

app.Documents(docs);
docs.Item(VVariant(1L), doc);
doc.Pages(pages);
pages.Item(VVariant(1L), page);
page.Shapes(shapes);

shapes.Count(&numOfShape);

for(i=1; i<numOfShape; i++)
{
name = NULL;
shapes.Item(VVariant(i), shape);
shape.getName(VBstr(name));
AfxMessageBox(name);
SysFreeString(bstr);
}

AfxMessageBox expects a null terminated array of chars. VBstr is an
object. You need to convert the VBstr to a char* with something like...

TCHAR strChar[256];
ULONG size;
name.ConvertToLPTSTR(strChar, &size);
 

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