saphire99
12-24-2015, 04:11 AM
Hello to all,
Hope everyone is having a great day. :hi:
I have text to table problem I am trying to solve.:confused:
What I am trying to achieve:
If the text has an RGB back ground of lets say 220,220,220 - This text will need to be converted to a 3 Column table
If the text has a background color of RGB of 209,209,209 - This text will be converted to a 2 Column Table
I will use a pipe | as a delimiter.
Sub ConvertTextToTable()
Dim opara As String, i as long
'====Create a 3 Column Table
IF
opara.Range.Shading.BackgroundPatternColor = RGB(220,220,220)
Then
Selection.ConvertToTable Separator:=wdSeparateByDefaultListSeparator, _
NumColumns:=3, NumRows:=3, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
'=======Create a 2 Column Table
Else if
opara.Range.Shading.BackgroundPatternColor = RGB(209, 209, 209)
Selection.ConvertToTable Separator:=wdSeparateByDefaultListSeparator, _
NumColumns:=2, NumRows:= , AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
End With
End Sub
I thought of using bookmarks but - it becomes a bit messy as each document may have loads of different tables and managing the bookmark names -inserting, deleting may cause confusion later.
I don't know how many rows each table may have. So it needs a variable - of some kind - which I am yet to be acquainted with.
Later on It would be useful for me to convert back these tables to text.
I would really really appreciate the kind help from the professionals as I don't know how to complete this.
thank you so much in advance for helping me
Saphire
Hope everyone is having a great day. :hi:
I have text to table problem I am trying to solve.:confused:
What I am trying to achieve:
If the text has an RGB back ground of lets say 220,220,220 - This text will need to be converted to a 3 Column table
If the text has a background color of RGB of 209,209,209 - This text will be converted to a 2 Column Table
I will use a pipe | as a delimiter.
Sub ConvertTextToTable()
Dim opara As String, i as long
'====Create a 3 Column Table
IF
opara.Range.Shading.BackgroundPatternColor = RGB(220,220,220)
Then
Selection.ConvertToTable Separator:=wdSeparateByDefaultListSeparator, _
NumColumns:=3, NumRows:=3, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
'=======Create a 2 Column Table
Else if
opara.Range.Shading.BackgroundPatternColor = RGB(209, 209, 209)
Selection.ConvertToTable Separator:=wdSeparateByDefaultListSeparator, _
NumColumns:=2, NumRows:= , AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
End With
End Sub
I thought of using bookmarks but - it becomes a bit messy as each document may have loads of different tables and managing the bookmark names -inserting, deleting may cause confusion later.
I don't know how many rows each table may have. So it needs a variable - of some kind - which I am yet to be acquainted with.
Later on It would be useful for me to convert back these tables to text.
I would really really appreciate the kind help from the professionals as I don't know how to complete this.
thank you so much in advance for helping me
Saphire