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 08-04-2008, 11:55
vindaa
Guest
 
Posts: n/a
Default 2 Macros 1 Button

I have 2 macros and I want to use one button to avtivate them.

Like, If I just press the button ---Macro 1 is activated and
-----if while pressing the button Ctrl Key is down then Macro 2 is activated, How do I do that.

Sub Macro1()

Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
Dim eff1 As Effect
Set eff1 = OrigSelection(1).CreateContour(cdrContourOutside, 0.1, 5, cdrDirectFountainFillBlend, CreateCMYKColor(0, 0, 0, 100), CreateCMYKColor(0, 0, 0, 100), CreateCMYKColor(0, 0, 0, 100), 0, 0, cdrContourSquareCap, cdrContourCornerMiteredOffsetBevel, 15#)
eff1.Contour.ContourGroup.AddToSelection
ActiveSelection.Fill.UniformColor.CMYKAssign 0, 0, 100, 0
End Sub


Sub Macro2()

Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
Dim eff1 As Effect
Set eff1 = OrigSelection(1).CreateContour(cdrContourInside, 0.1, 5, cdrDirectFountainFillBlend, CreateCMYKColor(0, 0, 0, 100), CreateCMYKColor(0, 0, 0, 100), CreateCMYKColor(0, 0, 0, 100), 0, 0, cdrContourSquareCap, cdrContourCornerMiteredOffsetBevel, 15#)
eff1.Contour.ContourGroup.AddToSelection
ActiveSelection.Fill.UniformColor.CMYKAssign 0, 0, 100, 0
End Sub
Reply With Quote
  #2  
Old 08-04-2008, 13:40
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,770
Blog Entries: 10
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Control Key

The two subs you sent do the exact same thing I think. So I changed them a bit so you could see a working example:
Code:
Option Explicit
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Const VK_CONTROL = &H11

Sub CustomContour()
    Dim OrigSelection As ShapeRange
    Set OrigSelection = ActiveSelectionRange
    Dim eff1 As Effect

    Set eff1 = OrigSelection(1).CreateContour(cdrContourOutside, 0.1, 5, cdrDirectFountainFillBlend, CreateCMYKColor(0, 0, 0, 100), CreateCMYKColor(0, 0, 0, 100), CreateCMYKColor(0, 0, 0, 100), 0, 0, cdrContourSquareCap, cdrContourCornerMiteredOffsetBevel, 15#)
    
    If IsCtrlPressed() Then
        OrigSelection(1).Fill.UniformColor.CMYKAssign 0, 0, 100, 0
    Else
        OrigSelection(1).Fill.UniformColor.CMYKAssign 0, 100, 0, 0
    End If
End Sub

Private Function IsCtrlPressed() As Boolean
    IsCtrlPressed = (GetAsyncKeyState(VK_CONTROL) < 0)
End Function
Good Luck,

-Shelby
Reply With Quote
  #3  
Old 08-04-2008, 21:43
vindaa
Guest
 
Posts: n/a
Default

Great thanks a lot
Works fine, with many of my other macros too.

But how can I make it 'single click undo'

Previously I used to put my macros between
ActiveDocument.BeginCommandGroup "Make Table"
On Error GoTo ErrHandler
+
+
+
ErrHandler:
MsgBox "Error occured: " & Err.Description
Resume ExitSub

but I cant get it to work in this case, may be I am doing some thing wrong,
Reply With Quote
  #4  
Old 09-04-2008, 01:38
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,770
Blog Entries: 10
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default ExitSub:

You are missing the ExitSub that closes the Undo Group
Code:
ActiveDocument.BeginCommandGroup "My Undo Name"
On Error GoTo ErrHandler

+
+
+
+

ExitSub:
    ActiveDocument.EndCommandGroup
    Exit Sub

ErrHandler:
    MsgBox "Error occured: " & Err.Description
    Resume ExitSub
Hope that helps a little

-Shelby
Reply With Quote
  #5  
Old 11-04-2008, 20:24
vindaa
Guest
 
Posts: n/a
Default

Thanks a lot it, works
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
Corel, Options, Customization, Commands, macros, "Separ Rick Randall CorelDRAW/Corel DESIGNER VBA 5 14-05-2009 11:20
create a toolbar/menu for all my macros mgmcs Macros/Add-ons 2 25-05-2006 20:17
Problem the Macros with Corel X3 Paulo Neto Macros/Add-ons 0 10-05-2006 18:20
Cannot use Curveworks macros in a user witten macro??? jon46089 CurveWorks 2 02-03-2006 14:18
Corel 11 Macros dont show up??? xombie Macros/Add-ons 11 19-10-2005 16:16


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


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