如何用VC在EXCEL中加入文本框,并往里面写文本?如何设置文本框的边框STYLE?
我得代码如下,
................
................
CString str="hello";
lpDisp=sheet.AddTextbox(1,50,50,50,50);
Textbox textbox;
textbox.attachdispatch(lpDisp);
textbox.setText((LPCTSTR)str);
执行到最后一行出错;
我想会不会没有选中这个文本框对象的缘故。如果是的话,我该如何选中它呢?(另外还有这个帖子
http://www.csdn.net/expert/topic/1011/1011651.xml?temp=.6276819)

解决方案 »

  1.   

    try the following
    COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
    CString str="hello";
    lpDisp=sheet.AddTextbox(1,50,50,50,50);
    Textbox textbox;
    textbox.attachdispatch(lpDisp);
    textbox.Select(covOptional);
    textbox.setText((LPCTSTR)str);
      

  2.   

    试过了,似乎不行
    我现在用这种方法
    Shape shape=shapes.addShape(1,.....);
    TextFrame TF=shape.GetTextFrame();
    Characters chs=TF.Characters((COleVariant)(long)(1),(COleVariant)(long)(20));
    chs.SetText("Hello");
    觉得不是很爽,