U
Udo Nesshoever
Hi yall!
I'm calling Word as COM-Server from Delphi and from C++. I have to
retrieve the current position pretty frequently and I', using the
function Information of the object Range for that.
As a test I called this function heavily and after approx. 450 calls
Word shows an out-of-resources message box. I dont't know how to free
anything as I didn't see any possibility to do so.
Here are the snippets:
=== C++ ===
void MyClass::GetPositionInRange(
CRange &oRange, int &nRow, int &nColumn)
{
VARIANT vColumn =
oRange.get_Information(wdFirstCharacterColumnNumber);
VARIANT vLine =
oRange.get_Information(wdFirstCharacterLineNumber);
nRow = (int)vLine.lVal;
nColumn = (int)vColumn.lVal;
}
==========
=== Delphi ===
Deklaration:
var
i, j: Integer;
doc: OleVariant;
itm: OleVariant;
r: Range;
[...]
doc:= ExtractFilePath(ParamStr(0)) + 'problem.doc';
wApp.Documents.Open(doc, EmptyParam, ...);
itm:= 1;
wDoc.ConnectTo(wApp.Documents.Item(itm));
for i:= 0 to 30000 do
begin
r:= wDoc.Paragraphs.Item(2).Range;
j:= r.Information[wdFirstCharacterLineNumber];
end;
===========
Any hint is highly appreciated, as I couldn't find anything nor at
Google neither at MSDN
Cheers,
Udo
I'm calling Word as COM-Server from Delphi and from C++. I have to
retrieve the current position pretty frequently and I', using the
function Information of the object Range for that.
As a test I called this function heavily and after approx. 450 calls
Word shows an out-of-resources message box. I dont't know how to free
anything as I didn't see any possibility to do so.
Here are the snippets:
=== C++ ===
void MyClass::GetPositionInRange(
CRange &oRange, int &nRow, int &nColumn)
{
VARIANT vColumn =
oRange.get_Information(wdFirstCharacterColumnNumber);
VARIANT vLine =
oRange.get_Information(wdFirstCharacterLineNumber);
nRow = (int)vLine.lVal;
nColumn = (int)vColumn.lVal;
}
==========
=== Delphi ===
Deklaration:
var
i, j: Integer;
doc: OleVariant;
itm: OleVariant;
r: Range;
[...]
doc:= ExtractFilePath(ParamStr(0)) + 'problem.doc';
wApp.Documents.Open(doc, EmptyParam, ...);
itm:= 1;
wDoc.ConnectTo(wApp.Documents.Item(itm));
for i:= 0 to 30000 do
begin
r:= wDoc.Paragraphs.Item(2).Range;
j:= r.Information[wdFirstCharacterLineNumber];
end;
===========
Any hint is highly appreciated, as I couldn't find anything nor at
Google neither at MSDN
Cheers,
Udo