OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Corel User Forums > CorelDRAW > Macros/Add-ons

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 23-03-2011, 10:29
buga buga is offline
Senior Member
 
Join Date: Jan 2011
Posts: 114
Default affect only the selected text

Hello such.

You see, I found an interesting code that changes the space between lines of a text.



Sub DecreaseLineSpacing(): changeLineSpacingByStep -1, -0.1: End Sub
Sub IncreaseLineSpacing(): changeLineSpacingByStep 1, 0.1: End Sub
Sub DecreaseLineSpacing10(): changeLineSpacingByStep -10, -1: End Sub
Sub IncreaseLineSpacing10(): changeLineSpacingByStep 10, 1: End Sub

Sub changeLineSpacingByStep(pct, inc)
Dim sr As ShapeRange, s As Shape, p As TextRange, l
Set sr = ActiveSelectionRange: On Error GoTo clsbsDONE
ActiveDocument.BeginCommandGroup "change line spacing by " + CStr(pct) + "%" + " (" + CStr(inc) + " pt)"
Optimization = True
EventsEnabled = False
ActiveDocument.SaveSettings
ActiveDocument.PreserveSelection = False
For Each s In sr
If s.Type = cdrTextShape Then
If s.Text.IsArtisticText Then
With s.Text.Story
l = 0
Select Case .LineSpacingType
Case cdrPointLineSpacing: l = .LineSpacing + inc
Case cdrPercentOfPointSizeLineSpacing: l = .LineSpacing + pct
Case cdrPercentOfCharacterHeightLineSpacing: l = .LineSpacing + pct
Case cdrMixedLineSpacing: l = .LineSpacing
End Select
If Round(l, 3) > 0 Then .LineSpacing = l
End With
Else
For Each p In s.Text.Story.Paragraphs: l = 0
Select Case p.LineSpacingType
Case cdrPointLineSpacing: l = p.LineSpacing + inc
Case cdrPercentOfPointSizeLineSpacing: l = p.LineSpacing + pct
Case cdrPercentOfCharacterHeightLineSpacing: l = p.LineSpacing + pct
Case cdrMixedLineSpacing: l = p.LineSpacing
End Select
If Round(l, 3) > 0 Then p.LineSpacing = l
Next p
End If
End If
Next s
clsbsDONE:
ActiveDocument.PreserveSelection = True
ActiveDocument.RestoreSettings
EventsEnabled = True
Optimization = False
Application.CorelScript.RedrawScreen
ActiveDocument.EndCommandGroup
End Sub




But I like to modify it to do the same, but only for the selected text (within a text of a paragraph or artistic)

I would also like to do the same thing this macro, but instead of changing the spacing between the lines, change the font size (one by one, and tens)

Can you help please?

thanks in advance

Greetings

Last edited by buga; 23-03-2011 at 10:31.
Reply With Quote
  #2  
Old 23-03-2011, 11:23
buga buga is offline
Senior Member
 
Join Date: Jan 2011
Posts: 114
Default

This code is used to change the selected text:

ActiveShape.Text.Selection.Font = "Arial Black"
ActiveShape.Text.Selection.size = 10.5

And this for the entire text:

ActiveShape.Text.Font = "Arial Black"
ActiveShape.Text.size = 10.5

How do I get the macro works for both cases, without having different macros.?
Reply With Quote
  #3  
Old 23-03-2011, 17:32
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Quote:
Originally Posted by buga View Post
This code is used to change the selected text:

How do I get the macro works for both cases, without having different macros.?
Hi.
Try this:

Code:
Sub textChange1()
    If Not ActiveShape Is Nothing Then
        If ActiveShape.Type = cdrTextShape Then
            If ActiveShape.text.IsEditing Then
                ActiveShape.text.Selection.Font = "Arial Black"
                ActiveShape.text.Selection.Size = 10.5
            Else
                ActiveShape.text.Story.Font = "Arial Black"
                ActiveShape.text.Story.Size = 10.5
            End If
        Else
            MsgBox "This is not TEXT!"
        End If
    Else
        MsgBox "Nothing Selected!"
    End If
End Sub
-John
Reply With Quote
  #4  
Old 24-03-2011, 07:58
buga buga is offline
Senior Member
 
Join Date: Jan 2011
Posts: 114
Default

Jonh thank you very much, I'll try to implement your code to see if it works.

thanks again

Greetings
Reply With Quote
  #5  
Old 24-03-2011, 13:22
buga buga is offline
Senior Member
 
Join Date: Jan 2011
Posts: 114
Default

bufff I tried to implement the code that you taught me, but I can not work. (only increases the space in full text, but not in the selection.)

Could anyone help to combine the codes please?

thanks

Greetings
Reply With Quote
  #6  
Old 24-03-2011, 16:01
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi.
I guess I must have misunderstood.
The code above will change all text unless you have a section of the text selected for editing, then it would only change the highlighted/selected part.

-John
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
Select everything, affect only text Joe CorelDRAW/Corel DESIGNER VBA 18 06-11-2008 05:52
Remove Mirror form All Selected Text vindaa CorelDRAW/Corel DESIGNER VBA 2 12-07-2008 19:47
How selected a part of text TheFez CorelDRAW/Corel DESIGNER VBA 2 22-05-2008 07:07
Changing Selected text knowbodynow CorelDRAW/Corel DESIGNER VBA 2 17-10-2007 08:49
Where is the selected text? petig CorelDRAW/Corel DESIGNER VBA 7 16-05-2005 15:30


All times are GMT -5. The time now is 20:16.


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