![]() |
|
|
#1
|
|||
|
|||
|
Помогите пожалуйста. Функции
WordApplication1.Documents.Add(EmptyParams, EmptyParams, EmptyParams, EmptyParams); WordApplication1.Documents.Open(Filenamе, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam); Выводят ошибку:Project Ik.exe raised exception class EOLeException with message 'Несовпадение типов' Подскажите пожалуйста из-за чего это происходит и как от этого избавиться? |
|
#2
|
|||
|
|||
|
implementation
var W:variant; Код:
Function CreateWord:boolean;
begin
CreateWord:=true;
try
W:=CreateOleObject('Word.Application');
except
CreateWord:=false;
end;
End;
Function VisibleWord(visible:boolean):boolean;
begin
VisibleWord:=true;
try
W.visible:= visible;
except
VisibleWord:=false;
end;
End;
Function AddDoc:boolean;
Var Doc_:variant;
begin
AddDoc:=true;
try
Doc_:=W.Documents;
Doc_.Add;
except
AddDoc:=false;
end;
End;
Function SaveDocAs(file_:string):boolean;
begin
SaveDocAs:=true;
try
W.ActiveDocument.SaveAs(file_);
except
SaveDocAs:=false;
end;
End;
Function CloseDoc:boolean;
begin
CloseDoc:=true;
try
W.ActiveDocument.Close;
except
CloseDoc:=false;
end;
End;
Function CloseWord:boolean;
begin
CloseWord:=true;
try
W.Quit;
except
CloseWord:=false;
end;
End;
Function OpenDoc(file_:string):boolean;
Var Doc_:variant;
begin
OpenDoc:=true;
try
Doc_:=W.Documents;
Doc_.Open(file_);
except
OpenDoc:=false;
end;
End;
Function VisibleWord(visible:boolean):boolean;
begin
VisibleWord:=true;
try
W.visible:= visible;
except
VisibleWord:=false;
end;
End;//Использование: Код:
if CreateWord then begin
VisibleWord(true); //Показываем Ворд
If AddDoc then begin //Создаем документ
//OpenDoc('имя_документа'); //или открываем его
...........................
Делаем что хотим
...........................
SaveDocAs('c:\123'); //Сохраняем(если надо конечно)
CloseDoc; //закрываем документ
CloseWord;//и сам Ворд |
|
#3
|
|||
|
|||
|
Спасибо большое, теперь все работает)))
|