Hey guys, a few months ago I started programming in Corel. I added 4 or 5 fields to the Object Data, and I remember there being some difficultly with getting them to show in the Docker compared when to I was entering them in the Field Editor. I don't remember how exactly I got them to display. Maybe a close and reopen of Corel.
Fast forward to now, and I am unable to Create New Field. I click "Create New Field," it takes me to a blank line that I cannot type in. I double click the field and cannot type. I even tried to add the new data fields via VBA and as soon as I "add them," they do not exist, haha.
Is there something I am missing? Anyone else experience this?
Zeke
Loveland, CO
What version of CorelDRAW are you running?
Corel 2019 (64 BIT)
Version 21.3.0.755
I can add here that I have a macro that uses a couple of custom datafields (and creates those data fields, if they aren't already present in the document).
I had not tried that macro in 2019, but after reading your post here, I just did - and it does not work correctly. It generates an error when it tries to use a custom datafield that it just tried to create.
It's bizarre, isn't it? What you are experiencing is exactly my dilemma. I will update here if I find a solution.
If you learn anything about this, sure, that would be great! Of course, this should work!
I can think of some workarounds, but whether they are suitable or not would depend on the details of what you need to accomplish.
If I want to "attach" information to a document, or document page, or object when working with a macro, then I have mostly moved to using Properties. That's OK if I don't need to have the user be able to access that information through the Object Data docker or through the spreadsheet.
Another way to have a datafield available is to edit the ObjectData.xml file in the "user" Object Data folder (e.g., C:\Users\Eskimo\AppData\Roaming\Corel\CorelDRAW Graphics Suite 2019\Draw\Object Data). As a solution, that's pretty ugly.
I guess we'll see if I hear back from Corel Support. What are the capabilities of using the Properties? I'm not sure if that would work. My end goal is not to have the user access the information, so it sounds like it has potential. So instead of adding a Data field, I could add as many Properties as I'd like to an object?
A Property is addressed by specifying a Name (String) and an ID (Long). So, you can store multiple pieces of information using one Name, but with different ID values. So, something like:
Shape.Properties("MyProperty1",1) = "foo"
Shape.Properties("MyProperty1",2) = "bar"
is the sort of thing I have used it for.
In my Saved View Areas macro, I use document Properties and page Properties to store the information about the stored views.
One possible inconvenience comes from the fact that you can't directly include such Properties directly in a CQL query. Shelby Moore has posted about how that can be done using a custom function.
Awesome, I started playing with before you responded, and I think this will work, I guess I'll see if it can replace the Object Data.
I have a tab open with Shelby's CQL for that :) That is an impressive macro, I just watched the video and think that could come in handy. I am going to show that to our graphics team and see what they think. As always, thank you very much, Eskimo!
Okay, follow up question - once I add Properties data to shapes, save document, and close the document, if I reopen it, the data/propterties seems to disappear. Is there something else that I am missing?
I just tried using this in 2019 on a shape, and it worked as expected when I opened the same document later.
Sub save_shape_properties() Dim s As Shape Set s = ActiveShape s.Properties("MyProperty1", 1) = "foo" s.Properties("MyProperty1", 2) = "bar" End Sub '------------------------------------------------------------- Sub check_shape_properties() Dim s As Shape Set s = ActiveShape MsgBox "MyProperty1, ID 1: " & s.Properties("MyProperty1", 1) MsgBox "MyProperty1, ID 2: " & s.Properties("MyProperty1", 2) End Sub
Ahhh, I see what I did. I was migrating information from some ObjectData to the properties. I had some numbers in object data that it appears I needed to convert to a string in order store it in the properties.