Hello, people!This VBA form is my Christmas present from me to You. It can be used to duplicate selected shape/shapes in direction-Top, Right, Down, Left. You can set up quantity, direction of the duplicated shapes and distance between them. If no dirrection selected, the duplicated shapes are stacked on top of the originally selected one. I wish You a peaceful and happy New 2024 Year! Let all wars in the world stop now! VBE This Form Show is additive bonus to You!Greetings!
'Private buttonhandlers As Collection 'must be at top of ufCommands codePrivate Sub cb_Bottom_Click()Dim S1 As ShapeRange Set S1 = ActiveSelectionRange Dim S2 As ShapeRange Set S2 = S1.Duplicate(0, -S1.SizeHeight - tbDistance / 25.4) S1.RemoveFromSelection S2.Shapes.All.AddToSelectionEnd Sub
Private Sub cb_Left_Click() Dim S1 As ShapeRange Set S1 = ActiveSelectionRange Dim S2 As ShapeRange Set S2 = S1.Duplicate(-S1.SizeWidth - tbDistance / 25.4, 0) S1.RemoveFromSelection S2.Shapes.All.AddToSelectionEnd Sub
Private Sub cb_Right_Click()
Dim S1 As ShapeRange Set S1 = ActiveSelectionRange Dim S2 As ShapeRange Set S2 = S1.Duplicate(S1.SizeWidth + tbDistance / 25.4, 0) S1.RemoveFromSelection S2.Shapes.All.AddToSelectionEnd Sub
Private Sub cb_Top_Click() Dim S1 As ShapeRange Set S1 = ActiveSelectionRange Dim S2 As ShapeRange Set S2 = S1.Duplicate(0, S1.SizeHeight + tbDistance / 25.4) S1.RemoveFromSelection S2.Shapes.All.AddToSelectionEnd Sub
Private Sub cbDuplicateBottom_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)cbDuplicateRight = FalsecbDuplicateTop = FalsecbDuplicateLeft = FalseEnd Sub
Private Sub cbDuplicateLeft_Click()End Sub
Private Sub cbDuplicateLeft_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)cbDuplicateBottom = FalsecbDuplicateRight = FalsecbDuplicateTop = FalseEnd Sub
Private Sub cbDuplicateRight_Click()
End Sub
Private Sub cbDuplicateRight_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)cbDuplicateBottom = FalsecbDuplicateTop = FalsecbDuplicateLeft = FalseEnd Sub
Private Sub cbDuplicateTop_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)cbDuplicateBottom = FalsecbDuplicateRight = FalsecbDuplicateLeft = FalseEnd Sub
Private Sub CommandButton1_Click()Application.GlobalUserData("meTopLeft", 1) = Me.TopApplication.GlobalUserData("meTopLeft", 2) = Me.Left
Me.HideEnd Sub
Private Sub CommandButton6_Click()On Error GoTo errorhandler
Dim S1 As ShapeRange, S2 As ShapeRange'DUPLICATE RIGHTIf Me.cbDuplicateRight ThenFor X = 1 To Me.tbDuplicate.Value cb_Right_ClickNextEnd If
'DUPLICATE LEFTIf Me.cbDuplicateLeft ThenFor X = 1 To Me.tbDuplicate.Valuecb_Left_ClickNextEnd If
'DUPLICATE TOPIf Me.cbDuplicateTop ThenFor X = 1 To Me.tbDuplicate.Valuecb_Top_ClickNextEnd If
'DUPLICATE BOTTOMIf Me.cbDuplicateBottom ThenFor X = 1 To Me.tbDuplicate.Valuecb_Bottom_ClickNextEnd If
If Me.cbDuplicateRight = False And Me.cbDuplicateLeft = False And Me.cbDuplicateTop = False And Me.cbDuplicateBottom = False ThenFor X = 1 To Me.tbDuplicate.Value'Dim S1 As ShapeRange Set S1 = ActiveSelectionRange' Dim S2 As ShapeRange Set S2 = S1.Duplicate(0, 0) S1.RemoveFromSelection S2.Shapes.All.AddToSelection
NextEnd IfExit Suberrorhandler:MsgBox "PERHAPS NO SHAPE SELECTED. PLEASE SELECT ONE AND TRY AGAIN"End Sub
Private Sub CommandButton7_Click()Dim mwind As VBIDE.Window'from excel'Application.VBE.VBProjects(Application.VBE.SelectedVBComponent.VBE.ActiveVBProject.Name).VBComponents(mycontrol.Parent.Name).Activate'UNSELECT ALLDim BHBP_shape_range As ShapeRangeSet BHBP_shape_range = ActiveSelectionRangeDim s As Shape For Each s In ActiveSelection.Shapes 'If s.Type = cdrRectangleShape Then s.Selected = False s.Selected = False Next s'UNSELECT ALL'Application.GlobalUserData("meTopLeft", 1) = Me.Top'Application.GlobalUserData("meTopLeft", 2) = Me.Left
Dim vbeditor As VBIDE.VBEApplication.VBE.MainWindow.Visible = True'Set WshShell = CreateObject("WScript.Shell")'WshShell.SendKeys "^g"'Debug.Print "immediate_window_BhBp_clear"
Set vbeditor = Application.VBE''''''''''''''''MsgBox vbeditor.VBProjects("GlobalMacros").VBComponents.Count'''''''''''''''''''''''''''''''vbeditor.VBProjects("GlobalMacros").VBComponents("ufCommands").Activate'''''''''''''''''''''''''''''''vbeditor.VBProjects("GlobalMacros").VBComponents(Me.Name).Activate
vbeditor.ActiveVBProject.VBComponents(Me.Name).Activate
BHBP_shape_range.CreateSelection
'vbeditor.ActiveVBProject.VBComponents("ufCommands").Activate
Private Sub CommandButton8_Click()MsgBox Application.Name & " " & Application.VersionMajor
End SubPrivate Sub CommandButton9_Click()End Sub
Private Sub Image1_Click()Shell ("Explorer ">https://www.bhbp.bg")End Sub
Private Sub Label6_Click()
Private Sub UserForm_Activate()'uf_BhBp_Duplicate_X3.Left = 50FLAG = 0On Error Resume Next 'if data field exist ActiveDocument.DataFields.AddEx2 "", "webcgm", "DleftX", cdrDataTypeNumber, "", "", "", "", True, True, FalseOn Error Resume Next 'if data field exist ActiveDocument.DataFields.AddEx2 "", "webcgm", "DrightX", cdrDataTypeNumber, "", "", "", "", True, True, False On Error Resume Next 'if data field exist ActiveDocument.DataFields.AddEx2 "", "webcgm", "DsizeWidth", cdrDataTypeNumber, "", "", "", "", True, True, FalseOn Error Resume Next 'if data field exist ActiveDocument.DataFields.AddEx2 "", "webcgm", "DsizeHeight", cdrDataTypeNumber, "", "", "", "", True, True, FalseOn Error Resume Next 'if data field exist ActiveDocument.DataFields.AddEx2 "", "webcgm", "DtopY", cdrDataTypeNumber, "", "", "", "", True, True, FalseOn Error Resume Next 'if data field exist ActiveDocument.DataFields.AddEx2 "", "webcgm", "DbottomY", cdrDataTypeNumber, "", "", "", "", True, True, FalseMe.Top = Application.GlobalUserData("meTopLeft", 1)Me.Left = Application.GlobalUserData("meTopLeft", 2)End SubPrivate Sub UserForm_Click()
End SubPrivate Sub UserForm_Initialize()uf_BhBp_Duplicate_X5.Left = 50'Dim Ctrl As Control'Dim Ctrl1 As Control'Dim ButtonHandler As ButtonEventHandler'Set buttonhandlers = New Collection'For Each Ctrl In Me.Controls' If TypeName(Ctrl) = "CommandButton" Then' Set ButtonHandler = New ButtonEventHandler' Set ButtonHandler.CommandButton = Ctrl' buttonhandlers.Add ButtonHandler' End If'Next CtrlEnd Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)Application.GlobalUserData("meTopLeft", 1) = Me.TopApplication.GlobalUserData("meTopLeft", 2) = Me.LeftEnd Sub
Hello, againPlease follow this link https://www.bhbp.bg/product/455/bhbp-duplicate-form-v-2.html to download *.frm file to import to Your CorelDRAW VBA project (BG)Or this link for EN - https://www.bhbp.bg/en/product/455/.html Just download, unzip and import to Your CorelDRAW VBA Project. To access this form from all opened Corel files, import to globalmacros.gms
My VB Clock project is here: https://www.bhbp.bg/en/product/453/.html
Greetings!