Hi.
Holding a key modifies the fucntion of a macro.
Ie hold shift and run the macro and it does this, hold Crtl and it does this... etc.
A great way to make your macros multi functional.
I also lightly touch base on Option Explicit which makes variable declaration necessary.
I also quickly talk about If, Else, ElseIf conditionals and colors.
Enjoy! (the code is pasted below)
~John
Option Explicit#If VBA7 Then Private Declare PtrSafe Function GetAsyncKeyState Lib "user32" (ByVal vKey As LongPtr) As Integer#Else Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer#End If'Private Const VK_ESCAPE = &H1B'Private Const VK_RETURN = &HDPrivate Const VK_SHIFT = &H10Private Const VK_CONTROL = &H11Sub makeRect() Dim s As Shape, sRect As Shape Dim x As Double, y#, h#, w# Dim dMarg# Dim col As New Color If GetAsyncKeyState(VK_SHIFT) Then dMarg = 0.25 col.RGBAssign 255, 0, 0 ElseIf GetAsyncKeyState(VK_CONTROL) Then dMarg = 0.25 col.RGBAssign 255, 0, 0 Else dMarg = 0.1 col.RGBAssign 0, 0, 255 End If ActiveDocument.Unit = cdrInch Set s = ActiveShape If s Is Nothing Then Exit Sub 's.GetBoundingBox x, y, w, h myGetBoundingBox s, x, y, w, h Set sRect = ActiveLayer.CreateRectangle2(x - dMarg, y - dMarg, w + (dMarg * 2), h + (dMarg * 2)) sRect.Fill.UniformColor.CopyAssign col sRect.OrderToBack End SubPrivate Function myGetBoundingBox(ByVal s As Shape, ByRef x As Double, y#, w#, h#) h = s.SizeHeight w = s.SizeWidth ActiveDocument.ReferencePoint = cdrBottomLeft x = s.PositionX y = s.PositionYEnd Function
I've started adding these posts to my favorites page here on coreldraw.com, that way I can find them all in one place. Hugh suggested posting them on the Wikis How-to's page, have you given that any thought?
Haven't had a chance to watch them all yet, but wow, John, these videos are super helpful. I've already learned some new things that will help me a great deal.
Thank you for being so generous!
Patti
pranderson said:I've started adding these posts to my favorites page here on coreldraw.com, that way I can find them all in one place. Hugh suggested posting them on the Wikis How-to's page, have you given that any thought?
Hi Patti.
You guys can make a wiki if ya want. Just post a link to each forum post and it would be easy that way.
Glad it helped. Can't wait to see some new ideas from everyone!
Thanks for the thanks!
RunFlaCruiser said:You guys can make a wiki if ya want. Just post a link to each forum post and it would be easy that way.
Consider it done. I placed in under How to & Tips & Tricks.
I added the link to your website at the bottom of the Wiki page. Edit the wiki page as you wish, John, or add an intro paragraph if you want. It's so kind of you to share these videos/lessons, we all thank you!
Thanks again.