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.
Another way to show the Document Properties dialog:
1 2 3
Sub open_document_properties() Application.FrameWork.Automation.InvokeItem "3324df3f-e302-4946-8ba9-6b1511700818" End Sub
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:
In some time ago i starting a project to explore drawui.xml but never finish him, a little demo
That is very interesting!
Would you be willing to share what you are doing in your code when "Try highlight this" is used?
Is a simple code, you use "FrameWork.Automation.GetItemScreenRect" to get a Rectangle in user screen, after this call a fullscreen semi transparent form and draw the rectangle to make total transparent area
Thank you!