Ö
Örjan Skoglösa
(Newbie with Powerpoint and first posting here)
I´m trying to go through some ppt-files and replace some of the
paragraph marks with blanks.
As it not seems to be possible to do so with normal S&R (?) I´m
trying to use a VBA-code that iterates through all the characters in
the presentation and checks them for being carriage returns (ASC =
13). If so, the character is replaced by a blank.
It works well on the first slide, but when it should go to the next
slide it stops at the line ' myChar.Select' and shows the following
error code:
Run time error '-2147188160 (80048240)
TextRange.Select: Invalid request.
The window must be in slide or note view.
If I add 'On Error Resume Next' at the top of the code, the code
execution does loop infinitely on the last para mark in the first
slide.
Any help very much appreaciated.
Örjan
Sub Replace_CR()
' On Error Resume Next
For Each sld In Application.ActivePresentation.Slides
For Each shp In sld.Shapes
With shp.TextFrame
If .HasText Then
For Each myChar In .TextRange.Characters
If Asc(myChar) = 13 Then
myChar.Select
MsgBox "test"
ActiveWindow.Selection.TextRange.Delete
ActiveWindow.Selection.TextRange.InsertBefore (" ")
MsgBox "test"
End If
Next myChar
End If
End With
Next shp
Next sld
End Sub
I´m trying to go through some ppt-files and replace some of the
paragraph marks with blanks.
As it not seems to be possible to do so with normal S&R (?) I´m
trying to use a VBA-code that iterates through all the characters in
the presentation and checks them for being carriage returns (ASC =
13). If so, the character is replaced by a blank.
It works well on the first slide, but when it should go to the next
slide it stops at the line ' myChar.Select' and shows the following
error code:
Run time error '-2147188160 (80048240)
TextRange.Select: Invalid request.
The window must be in slide or note view.
If I add 'On Error Resume Next' at the top of the code, the code
execution does loop infinitely on the last para mark in the first
slide.
Any help very much appreaciated.
Örjan
Sub Replace_CR()
' On Error Resume Next
For Each sld In Application.ActivePresentation.Slides
For Each shp In sld.Shapes
With shp.TextFrame
If .HasText Then
For Each myChar In .TextRange.Characters
If Asc(myChar) = 13 Then
myChar.Select
MsgBox "test"
ActiveWindow.Selection.TextRange.Delete
ActiveWindow.Selection.TextRange.InsertBefore (" ")
MsgBox "test"
End If
Next myChar
End If
End With
Next shp
Next sld
End Sub