OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Thread Tools Search this Thread Display Modes
Old 01-06-2008, 00:28
knowbodynow knowbodynow is offline
Senior Member
Join Date: Mar 2006
Location: Hatsukaichi near Hiroshima
Posts: 434
Default Removing lines of text

Hello I have some paragraph text. How can I compare each line of the paragraph text to each page name in a document and if the text matches any page name delete that line of text?


Chris (Hunt)
Reply With Quote
Old 01-06-2008, 11:01
Alex's Avatar
Alex Alex is offline
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4

Here is how:

Sub DeletePageNames()
    Dim txt As TextRange
    Dim trPara As TextRange
    Dim i As Long
    Dim p As Page
    Dim lookUpList As String
    Set txt = ActiveShape.Text.Story
    ' Create a Carriage-Return separated list of page names
    For Each p In ActiveDocument.Pages
        If p.Name <> "" Then lookUpList = lookUpList & p.Name & vbCr
    Next p
    ' Go through paragraphs in the text object and see if they have any page names
    For i = txt.Paragraphs.Count To 1 Step -1
        Set trPara = txt.Paragraphs(i)
        If InStr(lookUpList, trPara.Text) <> 0 Then
            ' Paragraph has one of the page names
            ' Delete it
        End If
    Next i
End Sub
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Identifying specific lines of paragraph text knowbodynow CorelDRAW/Corel DESIGNER VBA 3 06-12-2007 03:58
leading (line spacing) between lines of artistic text that have different font size michael_maberly General 4 15-07-2007 12:07
Striping a word down to the first letter only knowbodynow CorelDRAW/Corel DESIGNER VBA 9 19-04-2007 16:14
Text selection and sizing ddonnahoe CorelDRAW/Corel DESIGNER VBA 5 17-05-2005 14:19
Reset text after text compression. Bellekom CorelDRAW/Corel DESIGNER VBA 2 05-05-2004 07:14

All times are GMT -5. The time now is 08:11.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com