How can I do this in delphi?

On http://word.mvps.org/FAQs/TblsFldsFms/FastTables.htm

There is some tip on how to maximize the performence using word and ole.

I wounder how I can do this routin in delphi:

Dim oCell As Cell

Application.ScreenUpdating = False
Selection.Tables(1).Select
For Each oCell In Selection.Cells
    oCell.Range.Text = "Hi there"
Next oCell
Application.GoBack
Application.ScreenUpdating = True

End Sub


If I do:

WordApp.Table.Item(1).select.
for ix := 1 to WordApp.Selection.Cells.count-1 do
begin
  WordApp.Selection.Cells.Item(px).Range.Text:= 'aaaa';

end;


The selection seems to be modified.

If cells.count is 5 when I start it becomes 1 after the first time
  WordApp.Selection.Cells.Item(px).Range.Text:= 'aaaa';
has run.

LVL 2
wqclatreAsked:
Who is Participating?
 
pcsentinelConnect With a Mentor Commented:
try something like this

var
      ix: integer;
begin
      WordApp.Tables.Item(1).select;
      for ix := 1 to WordApp.ActiveWindow.Selection.Cells.count-1 do
      begin
        WordApp.Tables.Item(1).select;
          WordApp.ActiveWindow.Selection.Cells.Item(ix).Range.Text:= 'aaaa';
      end;
end;

regards
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.