Quick Question -
Is there a way to open Corel's Document Properties document via vba? I want to use it as a means to double check to see if the metadata i inputed via my macro stuck! Sometimes it doesn't so i'd like for the dialog box to pop up after to check.
I'm not certain what you mean by the "Document Properties document." I frequently need to verify SVG metadata, so I just keep the "Object Data Manager" docker active and usually open.
If what you want is the Document Properties dialog which is on the File menu, place this statement in your code where you would like the dialog to open...
SendKeys "%F." ' Note the period after the F
This sendkeys command performs the key presses ( Alt - F - . ) in the window the macro was called from. Ie. if you call your macro from the main corel window this code will send the appropriate key presses to open the Document Properties dialog. Note after opening the file menu with alt - F the period is the shortcut key to open the Document Properties dialog.
If you call your macro code from the VB Editor, sendkeys will open the file menu in the VB editor. The period will do nothing in the VB editor file menu because it is not a shortcut key there.
Another way to show the Document Properties dialog:
Thanks Eskimo! Awesome! I have been trying to figure out how to use control ID's. Your answer just taught me enough about Corel VBA to be dangerous .
Application.FrameWork.Automation.InvokeItem "3324df3f-e302-4946-8ba9-6b1511700818" ' ID = Document Properties dialog
This taught me that by using InvokeItem with a given ID, one can cleanly execute (invoke) most any menu or commandbar item directly from VBA using the ID of the control.
The Sendkeys method I posted earlier will do the job, however it is bug prone because it performs keyboard operations outside of the running code to achive its goal. I highly recomend using Eskimo's method instead.
For anyone needing a way to find the long control ID's, the code snippet below will return a list with the ID for each item on a given menu. The list appears on the debug screen, so you can easily copy and paste the ID's you need directly into your code.
sMenu = "the menu you need the control ID from"
Sub listMenuItemIDs() Dim cntrl As Control, sMenu As String sMenu = "File" ' or "Edit" or "View" or any menu you need an ID from. For Each cntrl In CommandBars(sMenu).Controls Debug.Print cntrl.ID, cntrl.Caption NextEnd SubWith minor changes this snippet can return ID's for controls on commandbars other than the menus.Thanks everyone for the question and the answer. This will solve so many things. Happy Coding!
I'm glad to hear that it will be of use to you!
Another forum member made me aware of Application.FrameWork.Automation.InvokeItem a while back when I was trying to help someone change - in a macro - the "Dynamic" property of new Dimensions that are created. I was using that to "push the button" to toggle Dynamic/not.
I later learned how to read from / write to the default Dimension style - VBA Setting document defaults. So, not very much experience with .InvokeItem, but I remembered it when I saw this thread.
That was all a workaround for the fact that Shape.Dimension.DynamicText = True/False appears to not work correctly - starting at least as far back as X7. That's not all that's broken with Dimensions, either. Ugh!
Thanks for sharing the tip on getting IDs!
I've gotten to where I do some of my workspace customization by editing the workspace.xml file (for example, using find-and-replace in a text editor to remove some Commands-I-rarely-use from the many context menus). Figuring out IDs is a big part of that, and when I find one of interest, I add it to my list.
To help keep track of menus and toolbars, and of things that I've added myself, in some cases I also add comments in the workspace.xml file: