Change setting using macro - Keep Desktop Objects on Layer

Has anyone figured out a way to have a macro read and change the setting for "Keep Desktop Objects on Layer" which is found on the Objects docker, "Gear"/settings menu? I would love to be able to check and change this using VBA.

  • Shark - you're awesome, dude! One line of code does the trick. Where do you find those long strings and know what they do?

    Here is my revised script allowing the user to change this setting via macro as needed.

    Sub KeepDesktopObjectsOnLayer(bKeep As Boolean)
    'bKeep (True/False): Keep Desktop Objects on Layer (On/Off)
    On Error GoTo Oops
    Dim WS As Object
    Dim RegKey As String

    Set WS = VBA.CreateObject("WScript.Shell")
    RegKey = "HKEY_CURRENT_USER\SOFTWARE\Corel\CorelDRAW\23.0\Draw\Application Preferences\VGDoc Pref Settings\KeepDesktopObjectsOnLayer"
    If WS.RegRead(RegKey) <> bKeep Then 'If the setting does not match with the request,
    Application.FrameWork.Automation.InvokeItem "53861e80-f191-4a0f-beaf-99c4f20aee44" 'toggle the setting
    End If

    Done:
    Set WS = Nothing
    Exit Sub

    Oops:
    MsgBox Err.Number & ": " & Err.Description
    Resume Done
    Resume 'For debugging

    End Sub