Duplicate Macro - Reg.

Sub DuplicateAndAlign()
Dim selectedObjects As selection
Set selectedObjects = ActiveDocument.ActiveSelection

' Check for correct selection count
If selectedObjects.count < 2 Then
MsgBox "Please select one object to duplicate and one or more objects to align to."
Exit Sub
End If

' Get references to the first and second sets of objects
Dim firstObject As shape
Set firstObject = selectedObjects(1)

Dim secondObjects As selection
Set secondObjects = selectedObjects.CreateSelection(2)

' Duplicate the first object
Dim duplicate As shape
Set duplicate = firstObject.duplicate

' Align the duplicate to each object in the second set
Dim currentObject As shape
For Each currentObject In secondObjects
' Align the duplicate to the current object (center alignment)
duplicate.centerX = currentObject.centerX
duplicate.centerY = currentObject.centerY
Next
End Sub

i have selected one object at the first set. this object is of any element of coreldraw (the first selected object) is automatically duplicated and aligned to center as per the second selected other objects (second set of selections) without asking any questions 

I want 2 versions 

1) selected object is duplicated and aligned to center of the other selections at once   (SELECTION)

2) selected object is duplicated and aligned to the same measurements of the first selected object in the document is replaced with the first selection. (ENTIRE DOCUMENT)

I tried using the  ChatGPT... but the above script is not working. please kindly update. 

  • 1) 1) selected object is duplicated and aligned to center of the other selections at once   (SELECTION)

     

    2) here same as above, but here it takes the main objects measurements and sees the entire document other objects whether it meets the main object measurements is equal, then only the main object is duplicated and aligned to the center to that exact measuremented object