Hello,
after importing the TLB from Aspose.Words from the directory where I unzipped the DLLs (t:\Aspose.Words\net4.0\Aspose.Words.dll / .tlb)
I try to access it in Delphi and want to open a document and want to save it to html.
procedure TForm1.Button1Click(Sender: TObject);
var
doc: _Document;
opendoc:_ComHelper;
begin
doc := CoDocument.Create;
opendoc:= CoComHelper.Create;
doc := opendoc.Open('Todo.docx');
doc.Save_2('ToDo.html', SaveFormat_Html);
opendoc:=Nil;
doc:=Nil;
CoUninitialize;
end;
In Opendoc.Open I get an error
Project Project1.exe raised exception class $C0000090 with message 'floating point invalid operation at 0x730dd2e6'.
How to fix this?
Stefan
@westner There were several reports about Aspose.Words used in Delphi leads to invalid floating point operation. To resolve this it is necessary to disable the Floating Point Exceptions by using Set8087CW($133f)
or SetExceptionMask(exAllArithmeticExceptions)
.
westner
November 1, 2023, 10:42am
3
Hello,
now my code looks like
procedure TForm1.Button1Click(Sender: TObject);
var
doc: _Document;
opendoc:_ComHelper;
begin
Set8087CW($133f);
doc := CoDocument.Create;
opendoc:= CoComHelper.Create;
doc := opendoc.Open('Todo.docx');
doc.Save_2('ToDo.html', SaveFormat_Html);
opendoc:=Nil;
doc:=Nil;
CoUninitialize;
end;
The floating point error is gone but doc.save_2 raises an access violation but this seems to occur after the todo.html is written.
Stefan
@westner Unfortunately, I am not quite familiar with Delphi. Could you please try using the following code (not sure about Delphi syntax)
Set8087CW($133f);
helper, doc: OLEvariant;
helper:= CreateOleObject("Aspose.Words.ComHelper");
doc:= helper.Open("C:\\Temp\\in.docx");
doc.Save("C:\\Temp\\out.html");
doc.Save("C:\\Temp\\out.html");
detect save format by the specified extension.
The code you provided worked.
1 Like