Notification texts go here Contact Us Buy Now!

MoveSelectedObjectsToNewLayers_Coreldraw_VBA

KHTM
MoveSelectedObjectsToNewLayers


Sub MoveSelectedObjectsToNewLayers()
    Dim s As Shape
    Dim lr As Layer
    Dim p As Page
    Dim sr As ShapeRange
    
    ' Check if any object is selected
    If ActiveSelection.Shapes.Count = 0 Then
        MsgBox "Please select the images you want to split into layers first!", vbExclamation
        Exit Sub
    End If
    
    ActiveDocument.BeginCommandGroup "Move to New Layers"
    Set p = ActivePage
    Set sr = ActiveSelectionRange
    
    ' Loop through all selected objects
    For Each s In sr
        ' Create a new layer using the object/file name
        On Error Resume Next
        Set lr = p.CreateLayer(s.Name)
        On Error GoTo 0
        
        ' Move that object to the newly created layer
        s.MoveToLayer lr
    Next s
    
    ActiveDocument.EndCommandGroup
    MsgBox "Successfully moved objects to new layers based on file names!", vbInformation
End Sub


Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.
/* Calculate Coil Length-Meter */ /* Calculate Coil Length-Meter-function */