::CoInitialize(NULL);
CLSID clsid;
#if 1
CLSIDFromProgID(L"Word.Application", &clsid);
Word::_ApplicationPtr pApp;
//pApp.GetActiveObject (clsid);
pApp.CreateInstance (clsid,NULL);
pApp ->PutVisible (VARIANT_TRUE);
_variant_t bstrFileName = "C:\\Project\\Îĵµ\\ftp•þÎñÉè¼Æ.doc";
pApp ->GetDocuments() ->Open (&bstrFileName);
//pApp ->GetDocuments() ->Add();
Word::_DocumentPtr pWordDocument =pApp-> GetActiveDocument();
Word::SelectionPtr pSelection = pApp ->GetSelection();
Word::ParagraphsPtr pParagraphs = pWordDocument->GetParagraphs ();
long lParaCnt = pParagraphs ->GetCount ();
Word::ParagraphPtr pTemp;
Word::RangePtr pRange;
for (long iLoop =1;iLoop{
pTemp = pParagraphs->Item (iLoop);
pRange = pTemp ->GetRange ();
printf("%s\n",(char*)pRange ->GetText());
printf("%s\n",(char*)(_bstr_t)pTemp->GetStyle ());
}
//pApp ->GetDocuments() ->Close ();
pApp ->Quit ();
#endif
#if 0
_variant_t varItem((long)1);
CLSIDFromProgID(L"Excel.Application", &clsid);
Excel::_ApplicationPtr pApp;
pApp .CreateInstance (clsid,NULL);
pApp ->PutVisible (0,VARIANT_TRUE);
Excel::_WorkbookPtr pWorkbook = pApp ->GetWorkbooks () ->Add ();
Excel::_WorksheetPtr pSheet = pWorkbook ->GetWorksheets () ->GetItem (varItem);
Excel::RangePtr pRange = pSheet ->GetUsedRange(0);
int iColCnt = pRange ->GetColumns() ->GetCount();
printf("used columns is %d\n",iColCnt);
int iRowCnt = pRange ->GetRows() ->GetCount();
printf("used rows is %d\n",iRowCnt);
pRange = pSheet ->GetRange(OLESTR("A1"));
pRange ->Value2 = OLESTR("zheng017");
pSheet ->GetRows ()-
Excel::InteriorPtr pInterior= pRange ->GetInterior ();
varItem.intVal = 0xff0000;
pInterior ->PutColor (varItem);
pSheet ->PrintPreview ();
#endif
::CoUninitialize();
return 0;
}