感受 WPS Office 2002 !
今天安装了WPS Office 2002,听说WPS Office 2002 提供了二次开发接口,于是迫不及待的试了一下,代码如下:
Variant WPS, DOC, Range;
try
{
WPS = CreateOleObject("WPS.Application");
}
catch (...)
{
MessageBox(Handle, "请确定您是否安装了WPS2002!", "错误", MB_OK | MB_ICONERROR);
}
WPS . OlePropertySet("Visible", true);
DOC = WPS . OlePropertyGet("Documents") . OleFunction("Add");
Range = DOC . OleFunction("Range", 1, 10);
Range . OlePropertySet("Text", "试验而已!");
DOC . OleProcedure("SaveAs", "c:\\a.wps");
WPS . OleProcedure("Quit");
但保存时总出现问题,于是到金山网站上找技术支持,终于看到了WPS Office 2002 的补丁,安装之后,程序终于可以正常运行。
于是本人在此提醒大家,在使用WPS Office 2002 的二次开发接口时,一定要安装WPS Office 2002 的补丁,最终的代码修改如下:
Variant WPS, DOC, Range;
try
{
WPS = CreateOleObject("WPS.Application");
}
catch (...)
{
MessageBox(Handle, "请确定您是否安装了WPS2002!", "错误", MB_OK | MB_ICONERROR);
}
WPS . OlePropertySet("Visible", true);
DOC = WPS . OlePropertyGet("Documents") . OleFunction("Add");
Range = DOC . OleFunction("Range", 1, 10);
Range . OlePropertySet("Text", "试验而已!");
try
{
DOC . OleProcedure("SaveAs", "c:\\a.wps");
}
catch (...)
{
MessageBox(Handle, "无法保存文件,请到www.wps.com.cn下载WPS补丁程序!", "错误", MB_OK | MB_ICONERROR);
DOC . OlePropertySet("Saved", true);
}
WPS . OleProcedure("Quit");
欢迎大家到http://bbs.cust.edu.cn/listboard.asp?boardid=80讨论。