![]() |
|
|
|
#1
|
||||
|
||||
|
Try: Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Par As Paragraph, Rng As Range
For Each Par In ActiveDocument.Paragraphs
If Par.Style = "Normal" Then
If Rng Is Nothing Then
Set Rng = Par.Range
Else
Rng.End = Par.Range.End
End If
Else
Call RngFmt(Rng)
End If
If Par.Range.End = ActiveDocument.Range.End Then
Call RngFmt(Rng)
End If
Next
Application.ScreenUpdating = True
End Sub
Sub RngFmt(Rng As Range)
If Not Rng Is Nothing Then
With Rng
If .Characters.Last.Information(wdWithInTable) = True Then
.Characters.Last.Next.InsertBefore "/>" & vbCr
.Characters.Last.Next.Style = "Normal"
Else
.End = .End - 1
.InsertAfter vbCr & "/>"
End If
If .Characters.First.Information(wdWithInTable) = True Then
.Characters.First.Previous.InsertBefore vbCr & "</"
.Characters.First.Previous.Style = "Normal"
Else
.InsertBefore "</"
End If
End With
Set Rng = Nothing
End If
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
| Tags |
| macro, macro help, table control, word 2007 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Can't insert space at the beginning of a line in Word
|
p89.schneider | Word | 6 | 03-24-2016 11:38 PM |
Macro to Insert text into the beginning on specific paragraphs unless the paragraph is blank
|
caboy | Word VBA | 2 | 04-01-2015 07:00 AM |
VBA code for Microsoft Word macro — select text and insert footnote
|
ndnd | Word VBA | 10 | 01-06-2015 01:47 PM |
Macro to insert multiple pictures to word to a specific size and text wrap
|
mescaL | Word VBA | 3 | 11-03-2014 10:51 PM |
| Looping macros to add text to beginning and end of a paragraph | pachmarhi | Word VBA | 0 | 02-16-2009 06:57 AM |