OberonPlace.com Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 22-04-2006, 11:25
fiddler2b
Guest
 
Posts: n/a
Default Select specified text, change font size?

Please, can you help me with VBA code for CorelDraw 12 or 3X?

In a 20-page CorelDraw document, I need a macro that selects a specific text string, and changes the font size (of only the selected text string). Each page has several text objects. I don't know how to identify the exact text object that contains the text string, but guess the macro can search through all text objects on the page. Optimization is not important here.

Goto page
Find/Select "My Text String That I Want to Change the Size Of"
Apply font size 8, face Arial
Goto next page
Reply With Quote
  #2  
Old 22-04-2006, 14:27
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

it will ask you twice. first time for string you search, second time for font name and size (separated by comma ",")

Code:
Sub changeFont()
   Dim p As Page, oldP As Page, sh As Shape, lookFor As String, i As Long, s As String
   Dim targetFont As String, targetSize As Integer, report As String, cnt As Long
   On Error Resume Next
   
   lookFor = InputBox("What to search", "text properties replace")
   If lookFor = "" Then Exit Sub
   
   s = InputBox("FontName, Size", "text properties replace", "Arial,8"): i = InStr(s, ",")
   If i = 0 Then targetSize = 8 Else targetSize = Val(Mid(s, i + 1)): s = left(s, i - 1)
   targetFont = Trim(s): If targetSize = 0 Then targetSize = 8
   
   report = "": Set oldP = ActivePage
   ActiveDocument.BeginCommandGroup "Replace " + lookFor
   For Each p In ActiveDocument.Pages
      p.Activate
      For Each sh In p.FindShapes
         If sh.Type = cdrTextShape Then
            i = InStr(UCase(sh.Text.Story), UCase(lookFor))
            Do While i > 0
               cnt = cnt + 1
               With sh.Text.Range(i - 1, i + Len(lookFor) - 1)
                  .Font = targetFont: .Size = targetSize
               End With
               i = InStr(i + 1, UCase(sh.Text.Story), UCase(lookFor))
            Loop
         End If
      Next sh
      If cnt > 0 Then _
         report = report + "Page " + CStr(p.Index) + ": " + CStr(cnt) + " times, ": cnt = 0
   Next p
   oldP.Activate: ActiveDocument.EndCommandGroup
   MsgBox IIf(report = "", "Not found", report)
End Sub
Reply With Quote
  #3  
Old 22-04-2006, 17:31
fiddler2b
Guest
 
Posts: n/a
Default Awsome!

wOxxOm:

One million thank yous! You are a total genius! The VBA you wrote worked perfectly!

How in the world did you do that so quickly???!!! Wow! Thank you, again.
Reply With Quote
  #4  
Old 23-04-2006, 08:11
wOxxOm's Avatar
wOxxOm wOxxOm is offline
Senior Member
 
Join Date: Mar 2005
Posts: 836
Default

Quote:
Originally Posted by fiddler2b
wOxxOm:

One million thank yous! You are a total genius! The VBA you wrote worked perfectly!

How in the world did you do that so quickly???!!! Wow! Thank you, again.
Because I wanted to outrun other gurus of this forum ;-))))
You're welcome, moreover this script will be useful for me too, by the way did you try Welcomescreen replacement - my beloved pet macro for CorelDraw? It's here on forums
Reply With Quote
Reply


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
Striping a word down to the first letter only knowbodynow CorelDRAW/Corel DESIGNER VBA 9 19-04-2007 15:14
Changing text size in CD12 knowbodynow CorelDRAW/Corel DESIGNER VBA 10 07-03-2006 07:13
how to specify the font size in inches bbolte CorelDRAW/Corel DESIGNER VBA 14 26-01-2005 22:19
InsertAfter - Retain Font Size Craig Tucker CorelDRAW/Corel DESIGNER VBA 3 07-01-2005 07:42
Reading Font Properties from selected text in CD9 sherman01 CorelDRAW/Corel DESIGNER VBA 2 24-11-2004 07:59


All times are GMT -5. The time now is 17:18.


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