R
Robert
Hello NG friends,
Can you please help this Newbie with two minor coding problems plus one
larger one?
1. Fragment-1 below works well but is far from elegant. Is there a more
economical way of generating Column Headers, please?
2. Fragment-2 doesn't work properly. The For - Next loop overwrites the
first column header set up in Fragment-1. How should I change the loop
to prevent that happening?
3. Columns 2,3 and 4 will be populated (starting in Row 2) using the
first three Items in the Collection of GetSpellingSuggestions for each
spelling error now shown in Column 1. (There will always be three
Suggestions, assigned to string variables called "cheat1, cheat2,
cheat3", even though some will remain empty.)
I have experimented without success to nest two For-Next loops so as to
display the (approx.) six sets of three Suggestions in my Table. Can
anyone please suggest a code framework that I might adapt?
Many thanks for any help.
Robert.
'FRAGMENT 1
With Selection
.Tables(1).Rows.Alignment = wdAlignRowCenter
.Tables(1).Select
.Font.Size = 12
.Collapse Direction:=wdCollapseStart
'Code below populates Column Headers in Row 1.
.TypeText " ERROR WORD "
.MoveRight Unit:=wdCell, Extend:=wdMove
.TypeText "SUGGESTION-1"
.MoveRight Unit:=wdCell, Extend:=wdMove
.TypeText "SUGGESTION-2"
.MoveRight Unit:=wdCell, Extend:=wdMove
.TypeText "SUGGESTION-3"
.MoveRight Unit:=wdCell, Extend:=wdMove
.TypeText " CORRECTION "
.MoveRight Unit:=wdCell 'Puts cursor in Col 1, Row 2. Necessary ??
End With
'FRAGMENT 2
oCount = 1
ActiveDocument.Tables(1).Rows(2).Select 'Doesn't solve problem !
For Each oCell In ActiveDocument.Tables(1).Columns(1).Cells
oCell.Range.Text = ActiveDocument.SpellingErrors(oCount)
oCount = oCount + 1
If oCount > i Then '(i = total no of errors in text)
Exit For
End If
Next oCell
'STILL PROBLEM: For - Next loop overwrites Column header in Row 1.
Can you please help this Newbie with two minor coding problems plus one
larger one?
1. Fragment-1 below works well but is far from elegant. Is there a more
economical way of generating Column Headers, please?
2. Fragment-2 doesn't work properly. The For - Next loop overwrites the
first column header set up in Fragment-1. How should I change the loop
to prevent that happening?
3. Columns 2,3 and 4 will be populated (starting in Row 2) using the
first three Items in the Collection of GetSpellingSuggestions for each
spelling error now shown in Column 1. (There will always be three
Suggestions, assigned to string variables called "cheat1, cheat2,
cheat3", even though some will remain empty.)
I have experimented without success to nest two For-Next loops so as to
display the (approx.) six sets of three Suggestions in my Table. Can
anyone please suggest a code framework that I might adapt?
Many thanks for any help.
Robert.
'FRAGMENT 1
With Selection
.Tables(1).Rows.Alignment = wdAlignRowCenter
.Tables(1).Select
.Font.Size = 12
.Collapse Direction:=wdCollapseStart
'Code below populates Column Headers in Row 1.
.TypeText " ERROR WORD "
.MoveRight Unit:=wdCell, Extend:=wdMove
.TypeText "SUGGESTION-1"
.MoveRight Unit:=wdCell, Extend:=wdMove
.TypeText "SUGGESTION-2"
.MoveRight Unit:=wdCell, Extend:=wdMove
.TypeText "SUGGESTION-3"
.MoveRight Unit:=wdCell, Extend:=wdMove
.TypeText " CORRECTION "
.MoveRight Unit:=wdCell 'Puts cursor in Col 1, Row 2. Necessary ??
End With
'FRAGMENT 2
oCount = 1
ActiveDocument.Tables(1).Rows(2).Select 'Doesn't solve problem !
For Each oCell In ActiveDocument.Tables(1).Columns(1).Cells
oCell.Range.Text = ActiveDocument.SpellingErrors(oCount)
oCount = oCount + 1
If oCount > i Then '(i = total no of errors in text)
Exit For
End If
Next oCell
'STILL PROBLEM: For - Next loop overwrites Column header in Row 1.