P
Popovic.Sasa
Hello everyone,
I need to do a simple task but I'm stuck with one problem.
I need to open Microsoft Excel and read it's custom document properties
from C++ (MFC). I was able to connect ot Excel and read a lot of things
(like Names, values in cells etc...) but I can't read custom document
properties. Here is the code I use:
CWorkbook xlBook;
LPDISPATCH lpDisp = NULL;
CCustomProperties properties;
lpDisp = m_ExcelApplication.get_ActiveWorkbook();
ASSERT(lpDisp);
xlBook.AttachDispatch(lpDisp);
lpDisp = NULL;
lpDisp = xlBook.get_CustomDocumentProperties();
ASSERT(lpDisp);
properties.AttachDispatch(lpDisp);
long count = properties.get_Count();
When I call "long count = properties.get_Count();" I receive exception
"member not found".
CWorkbok and CCustomProperties are classes that I generated from type
library using visual studio 2003.
Here is a code that works fine and reads all Names from Excel document:
CWorkbook xlBook;
LPDISPATCH lpDisp = NULL;
CNames names;
lpDisp = m_ExcelApplication.get_ActiveWorkbook();
ASSERT(lpDisp);
xlBook.AttachDispatch(lpDisp);
lpDisp = NULL;
lpDisp = xlBook.get_Names();
ASSERT(lpDisp);
names.AttachDispatch(lpDisp);
I would appriciate any help.
Thanks in advance,
Sasa
I need to do a simple task but I'm stuck with one problem.
I need to open Microsoft Excel and read it's custom document properties
from C++ (MFC). I was able to connect ot Excel and read a lot of things
(like Names, values in cells etc...) but I can't read custom document
properties. Here is the code I use:
CWorkbook xlBook;
LPDISPATCH lpDisp = NULL;
CCustomProperties properties;
lpDisp = m_ExcelApplication.get_ActiveWorkbook();
ASSERT(lpDisp);
xlBook.AttachDispatch(lpDisp);
lpDisp = NULL;
lpDisp = xlBook.get_CustomDocumentProperties();
ASSERT(lpDisp);
properties.AttachDispatch(lpDisp);
long count = properties.get_Count();
When I call "long count = properties.get_Count();" I receive exception
"member not found".
CWorkbok and CCustomProperties are classes that I generated from type
library using visual studio 2003.
Here is a code that works fine and reads all Names from Excel document:
CWorkbook xlBook;
LPDISPATCH lpDisp = NULL;
CNames names;
lpDisp = m_ExcelApplication.get_ActiveWorkbook();
ASSERT(lpDisp);
xlBook.AttachDispatch(lpDisp);
lpDisp = NULL;
lpDisp = xlBook.get_Names();
ASSERT(lpDisp);
names.AttachDispatch(lpDisp);
I would appriciate any help.
Thanks in advance,
Sasa