S
sunsong
Unregistered / Unconfirmed
GUEST, unregistred user!
我的机器是word 2000,前两天本程序运行良好,但现在运行后始终不出现WORD窗体,只是在进程中能看到'WINWORD.EXE',把本程序放到另外一个装WORD2002的'机器甲'上,运行良好.然而,同样是word2002的机器乙,跟我的反应一样,还是不出来,郁闷死人了!有没有人遇到过同样的问题?究竟怎么回事?
代码如下(delphi6,用D7也试过,一样):
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleServer, Word2000, DB, ADODB;
type
TForm1 = class(TForm)
TABLE1: TADOTable;
ADOConnection1: TADOConnection;
WordDocument1: TWordDocument;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Bookmark: TBookmark;
RangeW: Word2000.Range;
v1: Variant;
ov1: OleVariant;
Row1: Word2000.Row;
begin
WordDocument1.Activate;
WordDocument1.Connect ;
// insert title
WordDocument1.Range.Text := 'American Capitals from ' + Table1.TableName;
WordDocument1.Range.Font.Size := 14;
// disable the UI
Table1.DisableControls;
try
// store the current position
Bookmark := Table1.GetBookmark;
try
// scan the database table
Table1.First;
while not Table1.EOF do
begin
// send the two fields
WordDocument1.Range.InsertParagraphAfter;
WordDocument1.Paragraphs.Last.Range.Text :=
Table1.Fields[0].AsString + #9 +
Table1.Fields[1].AsString;
Table1.Next;
end;
finally
// go back to the bookmark and destroy it
Table1.GotoBookmark (Bookmark);
Table1.FreeBookmark (Bookmark);
end;
finally
// re-enable the controls
Table1.EnableControls;
end;
RangeW := WordDocument1.Content;
v1 := RangeW;
v1.ConvertToTable (#9, 19, 2);
Row1 := WordDocument1.Tables.Item(1).Rows.Get_First;
Row1.Range.Bold := 1;
Row1.Range.Font.Size := 30;
Row1.Range.InsertParagraphAfter;
ov1 := ' ';
end;
end.
代码如下(delphi6,用D7也试过,一样):
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleServer, Word2000, DB, ADODB;
type
TForm1 = class(TForm)
TABLE1: TADOTable;
ADOConnection1: TADOConnection;
WordDocument1: TWordDocument;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Bookmark: TBookmark;
RangeW: Word2000.Range;
v1: Variant;
ov1: OleVariant;
Row1: Word2000.Row;
begin
WordDocument1.Activate;
WordDocument1.Connect ;
// insert title
WordDocument1.Range.Text := 'American Capitals from ' + Table1.TableName;
WordDocument1.Range.Font.Size := 14;
// disable the UI
Table1.DisableControls;
try
// store the current position
Bookmark := Table1.GetBookmark;
try
// scan the database table
Table1.First;
while not Table1.EOF do
begin
// send the two fields
WordDocument1.Range.InsertParagraphAfter;
WordDocument1.Paragraphs.Last.Range.Text :=
Table1.Fields[0].AsString + #9 +
Table1.Fields[1].AsString;
Table1.Next;
end;
finally
// go back to the bookmark and destroy it
Table1.GotoBookmark (Bookmark);
Table1.FreeBookmark (Bookmark);
end;
finally
// re-enable the controls
Table1.EnableControls;
end;
RangeW := WordDocument1.Content;
v1 := RangeW;
v1.ConvertToTable (#9, 19, 2);
Row1 := WordDocument1.Tables.Item(1).Rows.Get_First;
Row1.Range.Bold := 1;
Row1.Range.Font.Size := 30;
Row1.Range.InsertParagraphAfter;
ov1 := ' ';
end;
end.