IDispatch *pTabels;
{
VARIANT vrTables;
VariantInit(&vrTables);
AutoWrap(DISPATCH_PROPERTYGET, &vrTables, pDoc, L"Tables", 0);
pTabels = vrTables.pdispVal;
}
// Get the count of the Tables and show it out
{
VARIANT vrCount;
VariantInit(&vrCount);
AutoWrap(DISPATCH_PROPERTYGET, &vrCount, pTabels, L"Count", 0);
CString strCount;
strCount.Format("The Tabels Count is %d\n", vrCount.intVal);
MessageBox(strCount);
}
// Get the tables's Rows
// 此处出错............................................................
IDispatch *pTableItem;
{
VARIANT vrTable;
VariantInit(&vrTable);
AutoWrap(DISPATCH_PROPERTYGET, &vrTable, pTabels, L"item", 1);
pTableItem = vrTable.pdispVal;
}
//....................................................................
要求读取所有的表格(Table)来.
{
VARIANT vrTables;
VariantInit(&vrTables);
AutoWrap(DISPATCH_PROPERTYGET, &vrTables, pDoc, L"Tables", 0);
pTabels = vrTables.pdispVal;
}
// Get the count of the Tables and show it out
{
VARIANT vrCount;
VariantInit(&vrCount);
AutoWrap(DISPATCH_PROPERTYGET, &vrCount, pTabels, L"Count", 0);
CString strCount;
strCount.Format("The Tabels Count is %d\n", vrCount.intVal);
MessageBox(strCount);
}
// Get the tables's Rows
// 此处出错............................................................
IDispatch *pTableItem;
{
VARIANT vrTable;
VariantInit(&vrTable);
AutoWrap(DISPATCH_PROPERTYGET, &vrTable, pTabels, L"item", 1);
pTableItem = vrTable.pdispVal;
}
//....................................................................
要求读取所有的表格(Table)来.
{
AFX_MANAGE_STATE(AfxGetStaticModuleState()); // TODO: 在此添加调度处理程序代码
LPDISPATCH lpDisp;
lpDisp=m_pWebOfficeFrame->m_pWebOfficeView->m_pSelection->GetIDispatch(); _Application_Word m_WordApp;
_Document_Word m_WordDoc;
Documents_Word m_WordDocs;
Range_Word m_WordRange;
Tables_Word m_WordTables;
Table_Word m_WordTable;
Columns_Word m_WordColumns;
Cell_Word m_WordCell; m_WordDoc.AttachDispatch(lpDisp,TRUE);
//m_WordDoc.Activate();
m_WordApp=m_WordDoc.GetApplication();
m_WordTables=m_WordDoc.GetTables(); DataPosition Position;
int iBeginPos,iEndPos,iBeginPos_,iEndPos_;
BOOL bInit,bAction,bInit_,bAction_;
bInit=TRUE;
bAction=FALSE;
CString m_RuleNode;
int iSerial;
iSerial=0;
int iSerialPos,iSerialPos_;
iSerialPos=0;
iSerialPos_=0;
BOOL bInit__,bAction__; char pResult[5];
memset(pResult,0,5); CString strRule_;
strRule_.Format("%s",strRule);
for(int iIndex=0;iIndex<strRule_.GetLength();iIndex++)
{
if(strRule_.GetAt(iIndex)=='#')
{
if(bInit)
{
iBeginPos=iIndex;
iEndPos=iIndex;
bInit=FALSE;
}
else
{
iBeginPos=iEndPos;
iEndPos=iIndex;
bAction=TRUE;
}
if(bAction)
{
m_RuleNode=strRule_.Mid(iBeginPos+1,iEndPos-iBeginPos-1);
bInit_=TRUE;
bAction_=FALSE;
for(int tIndex=0;tIndex<m_RuleNode.GetLength();tIndex++)
{
if(m_RuleNode.GetAt(tIndex)==',')
{
if(bInit_)
{
iBeginPos_=tIndex;
iEndPos_=tIndex;
bInit_=FALSE;
}
else
{
iBeginPos_=iEndPos_;
iEndPos_=tIndex;
bAction_=TRUE;
}
if(bAction_)
{
sprintf(pResult,"%s",m_RuleNode.Mid(iBeginPos_+1,iEndPos_-iBeginPos_-1));
if(iSerial==3)
{
iSerial=0;
}
switch(iSerial)
{
case 0:
Position.iTableSerial=atoi(pResult);
break;
case 1:
Position.iRow=atoi(pResult);
break;
case 2:
Position.iCol=atoi(pResult);
m_WordTable=m_WordTables.Item(Position.iTableSerial);
m_WordCell=m_WordTable.Cell(Position.iRow,Position.iCol);
m_WordRange=m_WordCell.GetRange();
iSerialPos++;
bInit__=TRUE;
bAction__=FALSE;
iSerialPos_=0;
m_WordRange.SetText(strSign);
m_WordTable.ReleaseDispatch();
m_WordRange.ReleaseDispatch();
m_WordCell.ReleaseDispatch();
break;
default:
break;
}
iSerial++;
bAction_=FALSE;
}
}
}
bAction=FALSE;
}
}
}
m_WordTables.ReleaseDispatch();
m_WordDoc.ReleaseDispatch();
m_WordApp.ReleaseDispatch();
}