View Single Post
 
Old 12-08-2016, 10:29 AM
ppayaw ppayaw is offline Windows 10 Office 2010 64bit
Novice
 
Join Date: Dec 2016
Posts: 5
ppayaw is on a distinguished road
Default Replacing any character with a space in the 1st position of every line in the document

Hi Paul,

Thanks for the reply. Let me first let you know that I'm a newbie and Im using the Internet to learn.

I tried your suggestion and it work on the first occurance. Not sure why it did not delete the rest of the document. Also I made a mistake in my request. I really need to replace everything in position 1 with a space. After running your code, I saw a problem. It shifted the line to the left and if the code work for the whole document, the document will look like teeth in a saw blade. Here is my code that examine the first character of each line and it working. I'm getting the page break and the line skips.
Dim intCntr
Dim FirstLine
intCntr = 0

For Each FirstLine In ActiveDocument.Paragraphs
intCntr = intCntr + 1
If Left(FirstLine, 1) = "1" Then
If intCntr > 1 Then
ActiveDocument.Paragraphs(intCntr).PageBreakBefore = True
End If
Else
If Left(FirstLine, 1) = "0" Then
ActiveDocument.Paragraphs(intCntr).LineUnitBefore = 2
Else
If Left(FirstLine, 1) = "-" Then
ActiveDocument.Paragraphs(intCntr).LineUnitBefore = 3
End If
End If

End If
Next FirstLine

Since I'm already examining the first character, Can I just assign a " " (space) to the variable? I just don't know how to access that variable.

Thanks once again to all,
Phil
Reply With Quote