V
Victoria
Admission: I'm horrible at code so the code below is probably VERY UGLY.
Task attempting: Have macro select TABLE and perform some tasks, then
select only the 1st COLUMN and perform additional tasks.
Problem: I can't seem to figure out how to clear the TABLE selection and
then select only column 1.
Code:
'Start TABLE selection and perform tasks
With Selection
.Sort ExcludeHeader:=False, FieldNumber:="Column 1", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="Column 1", SortFieldType2:=wdSortFieldNumeric,
SortOrder2 _
:=wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByDefaultTableSeparator, SortColumn:=False,
CaseSensitive:= _
False, LanguageID:=wdEnglishUS, SubFieldNumber:="Word 1",
SubFieldNumber2 _
:="Word 2", SubFieldNumber3:="Paragraphs"
End With
Selection.Tables(1).Select
Selection.Rows.HeightRule = wdRowHeightExactly
Selection.Rows.Height = InchesToPoints(0.16)
With Selection.ParagraphFormat
.SpaceBefore = 1.8
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.LineUnitBefore = 0
End With
'Start COLUMN selection and perform tasks
Selection.SelectColumn
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Task attempting: Have macro select TABLE and perform some tasks, then
select only the 1st COLUMN and perform additional tasks.
Problem: I can't seem to figure out how to clear the TABLE selection and
then select only column 1.
Code:
'Start TABLE selection and perform tasks
With Selection
.Sort ExcludeHeader:=False, FieldNumber:="Column 1", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="Column 1", SortFieldType2:=wdSortFieldNumeric,
SortOrder2 _
:=wdSortOrderAscending, FieldNumber3:="", SortFieldType3:= _
wdSortFieldAlphanumeric, SortOrder3:=wdSortOrderAscending,
Separator:= _
wdSortSeparateByDefaultTableSeparator, SortColumn:=False,
CaseSensitive:= _
False, LanguageID:=wdEnglishUS, SubFieldNumber:="Word 1",
SubFieldNumber2 _
:="Word 2", SubFieldNumber3:="Paragraphs"
End With
Selection.Tables(1).Select
Selection.Rows.HeightRule = wdRowHeightExactly
Selection.Rows.Height = InchesToPoints(0.16)
With Selection.ParagraphFormat
.SpaceBefore = 1.8
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
.LineUnitBefore = 0
End With
'Start COLUMN selection and perform tasks
Selection.SelectColumn
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll