读书人

:activeX 工程 调用 office ole 读写

发布时间: 2012-06-17 21:02:01 作者: rapoo

紧急求助:activeX 工程 调用 office ole 读写excel出错
我在CB6中建立普通的form exe程序,程序中使用 office ole 读写 excel文件没有问题,但是当我把此程序改写成一个activeX程序时调用OlePropertySet 时出错,内存非法访问,为什么呢?在activex程序中怎么使用office ole呢?

代码如下

#define PG OlePropertyGet
#define PS OlePropertySet
#define FN OleFunction
#define PR OleProcedure

void __fastcall TActiveTestFormX::btn1Click(TObject *Sender)
{

ExcelApp = Variant::CreateObject("Excel.Application");


ExcelApp.PS("Visible",(Variant)false); //在这报非法内存错误
}

各位帮忙,多谢!

[解决办法]
加了CoInitialize()了?

读书人网 >C++ Builder

热点推荐