dagerr
11-19-2018, 01:42 AM
Hi, the following code add text before every paragraph, it is not working correctly when at the begin of paragraph is hypen: "-".
Also is it possible to call this Sub only when this kind of table will appear in the document and stops where table is end?
example table: 23227:
Sub xml_tabela()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^t"
.Replacement.Text = "</td><td>"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Sub body_loop_xml()
Dim bRng As Range
Set bRng = ActiveDocument.Range
With bRng.Find
With .Font
.Size = 8
.bold = False
.Italic = False
End With
Do While .Execute(MatchWholeWord:=True)
bRng.End = bRng.Paragraphs(1).Range.End - 1
With bRng
.InsertBefore "<tr><td>"
.InsertAfter "</td></tr>"
.Collapse 0
End With
Loop
End With
Also is it possible to call this Sub only when this kind of table will appear in the document and stops where table is end?
example table: 23227:
Sub xml_tabela()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^t"
.Replacement.Text = "</td><td>"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Sub body_loop_xml()
Dim bRng As Range
Set bRng = ActiveDocument.Range
With bRng.Find
With .Font
.Size = 8
.bold = False
.Italic = False
End With
Do While .Execute(MatchWholeWord:=True)
bRng.End = bRng.Paragraphs(1).Range.End - 1
With bRng
.InsertBefore "<tr><td>"
.InsertAfter "</td></tr>"
.Collapse 0
End With
Loop
End With