VC中Range::Find的问题

来源:百度知道 编辑:UC知道 时间:2024/05/25 04:13:15
我想在Excel表中查找到指定字符后把当前的Range移过去
代码是这么写的:
m_App.CreateDispatch("Excel.Application",NULL);
m_workbooks.AttachDispatch(m_App.GetWorkbooks());
CString strPath("C:\\工作组.xlsx");
COleVariant vPath(strPath);
COleVariant vOpt((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
m_workbook.AttachDispatch(m_workbooks.Add(vPath));
m_sheets.AttachDispatch(m_workbook.GetSheets());
m_sheet.AttachDispatch(m_sheets.GetItem(COleVariant((long)1)));
m_Range.AttachDispatch(m_sheet.GetCells());
COleVariant vstr("完成功能"),vPos("A1"),vFalse((short)FALSE,VT_BOOL),v1((short)1),v2((short)2),vf4123((short)-4123);
m_Range.Find(vstr,vOpt,vf4123,v2,v1,1,vFalse,vFalse,vFalse);
m_Range.Activate();

但是运行后没有任何反映,Range根本没有移到 [完成功能] 上,请问高手~~
Find方法的第二个参数怎么写呀~~
或者哪们高手能给提供一个根据'字符串'在Excel表中查找的方法 谢谢~~

STDMETHODIMP FindText(
BSTR bstr,
long Count,
long Flags,
long *pLength
);

STDMETHODIMP FindTextEnd(
BSTR bstr,
long Count,
long Flags,
long *pLength
);

STDMETHODIMP FindTextStart(
BSTR bstr,
long Count,
long Flags,
long *pLength
);

bstr :
String to find.

Count :
Maximum number of characters to search. It can be one of the following.

Flags :
Flags governing comparisons. It can be 0 (the default) or any combination of the following. Match criterion Value Meaning
tomMatchWord 2 Matches whole words.
tomMatchCase 4 Matches case.
tomMatchPattern 8 Matches regular expressions.

pLength :
Pointer to a variable that receives the length of string matched.