gump996
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:10 回覆:8 積分:3 註冊:2002-10-18
發送簡訊給我
|
以下的程式碼是我在討論區中所搜尋到的,為何不能使用?
希望能有哪為前輩能指出錯誤在哪裡,感激不盡! Variant wordApp; if (wordApp.IsEmpty())
{
wordApp=Variant::CreateObject("Word.Application");
}
else
{
wordApp=GetActiveOleObject("Word.Application");
}
if (wordApp.IsEmpty())
{
ShowMessage("Unable to find Word application.");
return;
} wordApp.OlePropertySet("Visible", (Variant) true); Variant wordDocuments = wordApp.OlePropertyGet("Documents");
// creates a new document
wordDocuments.OleProcedure("Add"); Variant wordActiveDocument = wordApp.OlePropertyGet("ActiveDocument"); Variant wordTables = wordActiveDocument.OlePropertyGet("Tables"); Variant wordSelection = wordApp.OlePropertyGet("Selection"); Variant Range = wordSelection.OlePropertyGet("Range"); // inserts the table
wordTables.OleProcedure("Add", Range, (Variant) 3, (Variant) 5);
|
gemi0305
版主
![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif)
![](images/icon_photo_none.gif) 發表:81 回覆:564 積分:629 註冊:2003-05-11
發送簡訊給我
|
在前面記得要加上這行 ![]()
應該就行~ < class="code">
#include 國泰平安
|
gump996
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:10 回覆:8 積分:3 註冊:2002-10-18
發送簡訊給我
|
引言:
在前面記得要加上這行
應該就行~ < class="code">
#include 國泰平安
謝謝您的回覆,但是在測試上面的程式碼時,我已經有加入您所說的那一行了。
|
gemi0305
版主
![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif)
![](images/icon_photo_none.gif) 發表:81 回覆:564 積分:629 註冊:2003-05-11
發送簡訊給我
|
請問你出現的錯誤訊息是什麼?? ![]()
這裡有我
|
gump996
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:10 回覆:8 積分:3 註冊:2002-10-18
發送簡訊給我
|
引言:
請問你出現的錯誤訊息是什麼??
這裡有我>>< face="Verdana, Arial, Helvetica"> 感謝Gemi版主,我試了您所提供的code但是在我的Builder上無法compile通過。
應該是我的設定有問題吧,但我不知問題出在哪裡,還懇請多多指教,出現錯誤訊息如下: [C Error] sysvari.h(2561): E2450 Undefined structure 'TAutoArgs<1>'
[C Error] sysvari.h(2561): E2449 Size of 'args' is unknown or zero
[C Error] sysvari.h(2561): E2450 Undefined structure 'TAutoArgs<1>'
[C Error] sysvari.h(2562): E2094 'operator ' not implemented in type 'TAutoArgs<1>' for arguments of type 'int'
[C Error] sysvari.h(2563): E2450 Undefined structure 'TAutoArgs<1>'
[C Error] sysvari.h(2563): E2285 Could not find a match for 'Variant::OlePropertySet(const AnsiString,undefined)'
[C Error] sysvari.h(1246): E2450 Undefined structure 'TAutoArgs<3>'
[C Error] sysvari.h(1246): E2449 Size of 'args' is unknown or zero
[C Error] sysvari.h(1246): E2450 Undefined structure 'TAutoArgs<3>'
[C Error] sysvari.h(1247): E2094 'operator ' not implemented in type 'TAutoArgs<3>' for arguments of type 'int'
[C Error] sysvari.h(1247): E2094 'operator ' not implemented in type 'TAutoArgs<3>' for arguments of type 'int'
[C Error] sysvari.h(1247): E2094 'operator ' not implemented in type 'TAutoArgs<3>' for arguments of type 'int'
[C Error] sysvari.h(1248): E2450 Undefined structure 'TAutoArgs<3>'
[C Error] sysvari.h(1248): E2285 Could not find a match for 'Variant::OleProcedure(const AnsiString,undefined)'
|
gemi0305
版主
![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif)
![](images/icon_photo_none.gif) 發表:81 回覆:564 積分:629 註冊:2003-05-11
發送簡訊給我
|
呵,你可能是用bcb5寫的吧~
在bcb5之下的確會出現這些錯鋘訊息~
看看有沒有使用bcb5的版友,
有什麼解決的辨法~ ![]() 我是在
|
axsoft
版主
![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif) ![](./myimg/board/mystar.gif)
![](http://earthday.link.org.tw/images/EARTHfinal.gif) 發表:681 回覆:1056 積分:969 註冊:2002-03-13
發送簡訊給我
|
gump996您好:
試試下面的方法
//--------------------------------------------------------------------------- #include
#pragma hdrstop
#include
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender)
{
Variant word_app;
Variant word_docs;
Variant word_range;
Variant word_tables;
Variant word_table;
Variant active_doc;
Variant the_cell;
Variant cell_range;
int cell_width ;
int cell_long ; word_app=Variant::CreateObject("Word.application"); word_docs=word_app.OlePropertyGet("documents"); word_docs.OleProcedure("add"); word_app.OlePropertySet("Visible",true); active_doc=word_app.OlePropertyGet("ActiveDocument"); word_range=active_doc.OleFunction("Range"); word_tables=word_range.OlePropertyGet("Tables"); cell_width=5;
cell_long=20;
word_table=word_tables.OleFunction("Add",word_range,cell_long+1,cell_width);
//*****畫表格
Procedure InsertAfter("InsertAfter");
for(int i=0;i 結果
/*生活是一種藝術,用心生活才能享受生活*/
|
gump996
一般會員
![](./myimg/board/mystar_empty.gif)
![](images/icon_photo_none.gif) 發表:10 回覆:8 積分:3 註冊:2002-10-18
發送簡訊給我
|
感謝Gemi及Axsoft兩位版主的熱心幫忙,謝謝!
|