A
andreas
Dear Experts:
below macro converts the current selection (three lines with words
separated by tabs) into a table featuring 4 columns and three rows and
formats it with a user-defined table style.
Example (see code below):
text(tab) text(tab) text(tab) text
text(tab) text(tab) text(tab) text
text(tab) text(tab) text(tab) text
How can I expand the macro to perform the following tasks on any
selection:
Example:
.... retrieve the number of tabs in the first line of the current
selection (e.g. 6). 6 (six) tabs means 7 (seven) columns
.... retrieve the number of lines of the current selection (e.g. 8)
This variable number of columns (7) would be inserted into the
<NumColumns> part of the below code, the variable number of lines (3)
would be inserted into the <NumRows> part of the code.
So, summarizing the whole thing:
.... the code should identify the number of tabs in the first line of
the code
.... as well as the number of lines in the current selection and insert
the retrieved numbers in the macro code.
I hope I could make myself clear. Help is much appreciated. Thank you
very much in advance. Regards, Andreas
Sub Convert_Text_To_Table
Selection.ConvertToTable Separator:=wdSeparateByTabs,
NumColumns:=4, _
NumRows:=3, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "User-Defined-Table-Style"
End With
End Sub
below macro converts the current selection (three lines with words
separated by tabs) into a table featuring 4 columns and three rows and
formats it with a user-defined table style.
Example (see code below):
text(tab) text(tab) text(tab) text
text(tab) text(tab) text(tab) text
text(tab) text(tab) text(tab) text
How can I expand the macro to perform the following tasks on any
selection:
Example:
.... retrieve the number of tabs in the first line of the current
selection (e.g. 6). 6 (six) tabs means 7 (seven) columns
.... retrieve the number of lines of the current selection (e.g. 8)
This variable number of columns (7) would be inserted into the
<NumColumns> part of the below code, the variable number of lines (3)
would be inserted into the <NumRows> part of the code.
So, summarizing the whole thing:
.... the code should identify the number of tabs in the first line of
the code
.... as well as the number of lines in the current selection and insert
the retrieved numbers in the macro code.
I hope I could make myself clear. Help is much appreciated. Thank you
very much in advance. Regards, Andreas
Sub Convert_Text_To_Table
Selection.ConvertToTable Separator:=wdSeparateByTabs,
NumColumns:=4, _
NumRows:=3, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "User-Defined-Table-Style"
End With
End Sub