View Single Post
 
Old 01-17-2018, 12:57 PM
puff puff is offline Windows 7 64bit Office 2013
Advanced Beginner
 
Join Date: Apr 2017
Posts: 60
puff is on a distinguished road
Default How to express "or" in VBA? (code included)

Hi all. I have a document that has some empty lines start with "uppercase letter + ." like this:
2018-01-17_114845.png
Or simply start with "." like this:
2018-01-17_114818.png

My code so far can only remove the 2nd case
Code:
Sub DeleteLinesStartWith()

Dim oPara As Paragraph
Dim oRng As Range
Dim i As Integer
    For Each oPara In ActiveDocument.Paragraphs
        Set oRng = oPara.Range.Words(1)
        If LCase(Trim(oRng.Text)) = "." Then
            oPara.Range.Delete
        End If
    Next oPara
End Sub
1. The doc actually has other lines that I want to delete starting with some other signs, like "!". So how can I create a list/collection in the judging line for the macro?
If LCase(Trim(oRng.Text)) = "." Then

2. Some signs cannot be written in the VBA, like "•". In this case then, how can I delete an empty line start with "•"? Use the Unicode somehow?

Thank you very much.
Reply With Quote