S
Smylie
I am having a hard time deleting all section breaks from certain word
documents at work and have come up with these two MACRO codes form a previous
discussion to delete them.
(Simple Version)
Sub ScratchMacro()
Dim oRgn As Range
Set oRgn = ActiveDocument.Range
With oRgn.Find
..Text = Chr(12)
While .Execute
oRgn.Delete
oRgn.Collapse Direction:=wdCollapseEnd
Wend
End With
End Sub
(More Complex Version)
Sub ScratchMacro()
Dim i As Long
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
..Text = Chr(12)
While .Execute
oRng.Select
If oRng.Information(wdWithInTable) Then
oRng.MoveEnd wdCharacter, 1
oRng.Collapse wdCollapseStart
With Selection
..MoveRight Unit:=wdCharacter, Count:=1
..SplitTable
..MoveLeft Unit:=wdCharacter, Count:=1
..MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
..Delete Unit:=wdCharacter, Count:=1
..Delete Unit:=wdCharacter, Count:=1
End With
Else
oRng.Delete
oRng.Collapse Direction:=wdCollapseEnd
End If
Wend
End With
End Sub
However, I need to find a way to do this without deleting the page breaks as
well. Any help with this would be great.
Note: the ^b replace with nothing method does not work for the specific
files I am working with for some reason. I think it is because these breaks
are not seen by this command because they are in a table.
documents at work and have come up with these two MACRO codes form a previous
discussion to delete them.
(Simple Version)
Sub ScratchMacro()
Dim oRgn As Range
Set oRgn = ActiveDocument.Range
With oRgn.Find
..Text = Chr(12)
While .Execute
oRgn.Delete
oRgn.Collapse Direction:=wdCollapseEnd
Wend
End With
End Sub
(More Complex Version)
Sub ScratchMacro()
Dim i As Long
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
..Text = Chr(12)
While .Execute
oRng.Select
If oRng.Information(wdWithInTable) Then
oRng.MoveEnd wdCharacter, 1
oRng.Collapse wdCollapseStart
With Selection
..MoveRight Unit:=wdCharacter, Count:=1
..SplitTable
..MoveLeft Unit:=wdCharacter, Count:=1
..MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
..Delete Unit:=wdCharacter, Count:=1
..Delete Unit:=wdCharacter, Count:=1
End With
Else
oRng.Delete
oRng.Collapse Direction:=wdCollapseEnd
End If
Wend
End With
End Sub
However, I need to find a way to do this without deleting the page breaks as
well. Any help with this would be great.
Note: the ^b replace with nothing method does not work for the specific
files I am working with for some reason. I think it is because these breaks
are not seen by this command because they are in a table.