H
hq_pan
Unregistered / Unconfirmed
GUEST, unregistred user!
我在使用Word进行报表打印,是别人编写的,原来Delphi5中的是Office97包,我现在改为
Office 2000的包,程序里面的参数我也更改了,但是现在使用的时候出现错误:
=====================================================
Microsoft Visual Basic
The language DLL 'VBE6INTL.DLL' could not be found.
=====================================================
错误出现两次,然后word2000看不见了,但是后台进程还在。
请问这是怎么回事啊?是不是因为我装Office2000的时候没装全啊?
我在f:/Program Files/Common Files/Microsoft Shared/VBA/VBA6/2052/目录
下找到这个文件,但是是0字节的!(f盘是系统盘)
请问到底是什么原因啊??????
在线等待!!!急啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
下面是源代码:
===========================================================================
procedure TFormbaobiao.BitBtn1Click(Sender: TObject);
var
Template, NewTemplate, ItemIndex, ovDocumentType, ovVisible: OleVariant;
Start, Stop: OleVariant;
myRange: range;
WordTable: variant;
ColIndex, RowIndex: Integer;
I, j: Integer;
SQLstr, sqlstr1: string;
begin
if ListView2.Items.Count = 0 then
begin
Application.MessageBox('尚未选择打印客户范围,请先选择。', '提示',
MB_ICONINFORMATION + mb_Ok);
Exit;
end;
if ListView4.Items.Count = 0 then
begin
Application.MessageBox('尚未选择客户打印内容,请先选择。', '提示',
MB_ICONINFORMATION + mb_Ok);
Exit;
end;
Template := EmptyParam;
NewTemplate := True;
ItemIndex := 1;
Start := 3;
Stop := 3;
try
WordApplication.Connect;
except
//MessageDlg('Word may not be installed', mtError, [mbOk], 0);
MessageDlg('可能没有安装 Word', mtError, [mbOk], 0);
Abort;
end;
WordApplication.Visible := True;
WordApplication.Caption := '报表打印';
{Create new document}
Template := EmptyParam;
NewTemplate := False;
//WordApplication.Documents.Add(Template, NewTemplate);
ovDocumentType := Null;
ovVisible := True;
WordApplication.Documents.Add(Template, NewTemplate, ovDocumentType, ovVisible);
WordDocument.ConnectTo(WordApplication.Documents.Item(ItemIndex));
WordDocument.PageSetup.Orientation := wdOrientLandscape; //设置纸张横向输出打印
////////设置便距
WordDocument.PageSetup.LeftMargin := WordApplication.InchesToPoints(0.75);
WordDocument.PageSetup.rightMargin := WordApplication.InchesToPoints(0.75);
WordDocument.PageSetup.topMargin := WordApplication.InchesToPoints(0.90);
WordDocument.PageSetup.bottomMargin := WordApplication.InchesToPoints(0.75);
WordDocument.range.InsertAfter('报表' + #13);
WordDocument.range.InsertAfter(#13);
//-- 指定插入表的起始处 -------- //
myRange := WordDocument.range(Start, Stop);
//WordTable := WordDocument.Tables.Add(myRange, ListView2.Items.Count + 1,
// ListView4.Items.Count);
WordTable := WordDocument.Tables.Add(myRange, ListView2.Items.Count + 1,
ListView4.Items.Count, ovDocumentType, ovVisible);
//行数 // 列数
////////////////////////////////////////////////////////////
//////以上为华表个部分
//////打印列数,和打印行数已知,为listview2,listview4的行数
//////////////////////////////////////////////////////////
{
Formkhzldy.listview2.Items.Item[k].SubItems.strings[0];
}
{打印表头 }
ColIndex := 1;
for j := 0 to ListView4.Items.Count - 1 do
begin
WordTable.Cell(1, ColIndex).range.InsertAfter(ListView4.Items.Item[j].Caption);
ColIndex := ColIndex + 1;
end;
//准备数据
SQLstr := 'select ';
for I := 0 to ListView4.Items.Count - 1 do
begin
if I = 0 then
SQLstr := SQLstr + ListView4.Items.Item.SubItems.Strings[0]
else
SQLstr := SQLstr + ',' + ListView4.Items.Item.SubItems.Strings[0] + '';
end;
RowIndex := 2;
ColIndex := 1;
for I := 0 to ListView2.Items.Count - 1 do
begin
if TabControl1.ActiveTab = main.cPersonNo then
sqlstr1 := SQLstr + ' from grkhzl where khdm=''' +
ListView2.Items.Item.Caption + ''''
else
sqlstr1 := SQLstr + ' from jgkhzl where khdm=''' +
ListView2.Items.Item.Caption + '''';
with AQuery1 do
begin
Close;
SQL.Clear;
SQL.Append(sqlstr1);
Open;
end;
for j := 0 to DBGrid1.Columns.Count - 1 do
begin
if Trim(WordTable.Cell(1, ColIndex).range.Text) = '客户状态' then
begin
case AQuery1.FieldByName(DBGrid1.Columns[j].fieldname).AsInteger of
0: WordTable.Cell(RowIndex, ColIndex).range.InsertAfter('潜在客户');
1: WordTable.Cell(RowIndex, ColIndex).range.InsertAfter('现有客户');
2: WordTable.Cell(RowIndex, ColIndex).range.InsertAfter('历史客户');
end;
end
else
WordTable.Cell(RowIndex, ColIndex).range.InsertAfter
(AQuery1.FieldByName(DBGrid1.Columns[j].fieldname).AsString);
ColIndex := ColIndex + 1;
end;
RowIndex := RowIndex + 1;
ColIndex := 1;
end;
end;
Office 2000的包,程序里面的参数我也更改了,但是现在使用的时候出现错误:
=====================================================
Microsoft Visual Basic
The language DLL 'VBE6INTL.DLL' could not be found.
=====================================================
错误出现两次,然后word2000看不见了,但是后台进程还在。
请问这是怎么回事啊?是不是因为我装Office2000的时候没装全啊?
我在f:/Program Files/Common Files/Microsoft Shared/VBA/VBA6/2052/目录
下找到这个文件,但是是0字节的!(f盘是系统盘)
请问到底是什么原因啊??????
在线等待!!!急啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
下面是源代码:
===========================================================================
procedure TFormbaobiao.BitBtn1Click(Sender: TObject);
var
Template, NewTemplate, ItemIndex, ovDocumentType, ovVisible: OleVariant;
Start, Stop: OleVariant;
myRange: range;
WordTable: variant;
ColIndex, RowIndex: Integer;
I, j: Integer;
SQLstr, sqlstr1: string;
begin
if ListView2.Items.Count = 0 then
begin
Application.MessageBox('尚未选择打印客户范围,请先选择。', '提示',
MB_ICONINFORMATION + mb_Ok);
Exit;
end;
if ListView4.Items.Count = 0 then
begin
Application.MessageBox('尚未选择客户打印内容,请先选择。', '提示',
MB_ICONINFORMATION + mb_Ok);
Exit;
end;
Template := EmptyParam;
NewTemplate := True;
ItemIndex := 1;
Start := 3;
Stop := 3;
try
WordApplication.Connect;
except
//MessageDlg('Word may not be installed', mtError, [mbOk], 0);
MessageDlg('可能没有安装 Word', mtError, [mbOk], 0);
Abort;
end;
WordApplication.Visible := True;
WordApplication.Caption := '报表打印';
{Create new document}
Template := EmptyParam;
NewTemplate := False;
//WordApplication.Documents.Add(Template, NewTemplate);
ovDocumentType := Null;
ovVisible := True;
WordApplication.Documents.Add(Template, NewTemplate, ovDocumentType, ovVisible);
WordDocument.ConnectTo(WordApplication.Documents.Item(ItemIndex));
WordDocument.PageSetup.Orientation := wdOrientLandscape; //设置纸张横向输出打印
////////设置便距
WordDocument.PageSetup.LeftMargin := WordApplication.InchesToPoints(0.75);
WordDocument.PageSetup.rightMargin := WordApplication.InchesToPoints(0.75);
WordDocument.PageSetup.topMargin := WordApplication.InchesToPoints(0.90);
WordDocument.PageSetup.bottomMargin := WordApplication.InchesToPoints(0.75);
WordDocument.range.InsertAfter('报表' + #13);
WordDocument.range.InsertAfter(#13);
//-- 指定插入表的起始处 -------- //
myRange := WordDocument.range(Start, Stop);
//WordTable := WordDocument.Tables.Add(myRange, ListView2.Items.Count + 1,
// ListView4.Items.Count);
WordTable := WordDocument.Tables.Add(myRange, ListView2.Items.Count + 1,
ListView4.Items.Count, ovDocumentType, ovVisible);
//行数 // 列数
////////////////////////////////////////////////////////////
//////以上为华表个部分
//////打印列数,和打印行数已知,为listview2,listview4的行数
//////////////////////////////////////////////////////////
{
Formkhzldy.listview2.Items.Item[k].SubItems.strings[0];
}
{打印表头 }
ColIndex := 1;
for j := 0 to ListView4.Items.Count - 1 do
begin
WordTable.Cell(1, ColIndex).range.InsertAfter(ListView4.Items.Item[j].Caption);
ColIndex := ColIndex + 1;
end;
//准备数据
SQLstr := 'select ';
for I := 0 to ListView4.Items.Count - 1 do
begin
if I = 0 then
SQLstr := SQLstr + ListView4.Items.Item.SubItems.Strings[0]
else
SQLstr := SQLstr + ',' + ListView4.Items.Item.SubItems.Strings[0] + '';
end;
RowIndex := 2;
ColIndex := 1;
for I := 0 to ListView2.Items.Count - 1 do
begin
if TabControl1.ActiveTab = main.cPersonNo then
sqlstr1 := SQLstr + ' from grkhzl where khdm=''' +
ListView2.Items.Item.Caption + ''''
else
sqlstr1 := SQLstr + ' from jgkhzl where khdm=''' +
ListView2.Items.Item.Caption + '''';
with AQuery1 do
begin
Close;
SQL.Clear;
SQL.Append(sqlstr1);
Open;
end;
for j := 0 to DBGrid1.Columns.Count - 1 do
begin
if Trim(WordTable.Cell(1, ColIndex).range.Text) = '客户状态' then
begin
case AQuery1.FieldByName(DBGrid1.Columns[j].fieldname).AsInteger of
0: WordTable.Cell(RowIndex, ColIndex).range.InsertAfter('潜在客户');
1: WordTable.Cell(RowIndex, ColIndex).range.InsertAfter('现有客户');
2: WordTable.Cell(RowIndex, ColIndex).range.InsertAfter('历史客户');
end;
end
else
WordTable.Cell(RowIndex, ColIndex).range.InsertAfter
(AQuery1.FieldByName(DBGrid1.Columns[j].fieldname).AsString);
ColIndex := ColIndex + 1;
end;
RowIndex := RowIndex + 1;
ColIndex := 1;
end;
end;