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.
CorelDraw certainly saves the setting in the Registry when it closes, but it must also read it from there when it opens. My hope is that I can find a way to make it read and update this one setting while already running without having to do the equivalent of reloading an entire Workspace full of settings.
Try this:
Application.FrameWork.Automation.InvokeItem "53861e80-f191-4a0f-beaf-99c4f20aee44"
I ran this code twice and each time it toggled the "KeepDesktopObjectsOnLayer" state
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 OopsDim WS As ObjectDim 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
This is a very cool utility. Thank you so much!
I just downloaded it and I'm looking forward to checking it out.