I asked the CorelDRAW forums and we are all stumped on this one. Here's the thread with video.
I'm trying to add tags to my CorelDRAW file so I can make searching my library easier. I wrote my own "Save As" macro that opens the location and writes the file name based on my user form.
I tried adding a Tags section to my form to update the keywords of the document.
ActiveDocument.Metadata.Keywords = Tags.Value
Then I continue with the rest of my "Save As" code.
When I double checked the tags in windows, they're missing. In CorelDRAW I checked File>Document Properties and the tags are in there. Once I click OK, the file gets updated and I can resave. Only then, the tags show up in windows.
Eskimo from the CorelDRAW froums posted this:
You can open a CorelDRAW file in a .zip file editor (I use 7-Zip), and then navigate the archive that is the CorelDRAW file.
In the META-INF folder there, there is a metadata.xml file.
If I just use the VBA code to set keywords, and don't go through the document properties dialog, then I find this in the metadata.xml file for the document:
Screenshot of keywords added by VBA
I don't see any tags when looking at file details in Windows.
If I use the document properties dialog in CorelDRAW to set keywords, then I find this in the metadata.xml file for the document:
Screenshot of keywords added by Document Properties
I do see those as tags when looking at file details in Windows.
If I manually edit the lang="en" line in the XML file in the archive, then the tags that I see in Windows are those (edited) keywords.
So my question is how do I get my VBA code to update the keywords correctly, what would be the best way to go about this? Here's the code. Thanks!
Public Sub PTR_Btn_Click()
Dim sFolderPath As String
Dim sFileName As String
Dim ActNum As String
Dim sActFolder As String
Dim sFinalPath
Done = False
'Add Tags to Document
ActiveDocument.Metadata.Keywords = Tags.Value
MsgBox ActiveDocument.Metadata.Keywords
'Open Document Properties
Application.FrameWork.Automation.InvokeItem "3324df3f-e302-4946-8ba9-6b1511700818"
'How do I confirm or press ok on this menu to continue the macro?
'What do you want to find?
ActNum = Me.txtAct.Value
'Salesman Folder
sFolderPath = "D:\Sync\Sales Team\" & Me.Sales.Value & "\"
'Account Folder
sActFolder = Dir(sFolderPath & "*" & ActNum & "*", vbDirectory)
'If there is no folder then open form to create one
If sActFolder = "" Then
frmFolder.Show
If frmFolder.Cancel_Btn = True Then
Do While Done = False
DoEvents
Loop
End If
End If
sActFolder = Dir(sFolderPath & "*" & ActNum & "*", vbDirectory)
'Final Path
sFinalPath = sFolderPath & sActFolder & "\"
'MsgBox sFinalPath
'Open file save as dialog, you can change this to *.* to see all files
sFileName = CorelScriptTools.GetFileBox("CorelDRAW Files (*.cdr)|*.cdr", "Save As", 1, frmMain.txtAct.Value & "_" & "PTR" & "_" & Round(ActivePage.SizeWidth, 3) & "x" & Round(ActivePage.SizeHeight, 3) & "_" & Format(Now, "mmddyy"), , sFinalPath)
'User Canceled
If sFileName = " " Then
Exit Sub
End If
If sActFolder = " " Then
MsgBox "Folder Dosn't Exist."
End If
'If sign type is in the file, name then save
If sFileName Like "*PTR*" Then
ActiveDocument.SaveAs sFileName
GMSManager.RunMacro "JQ_Quick_Export", "JQ.Toggle_Quick_Export"
End If
End Sub
Tried to update existing vba macro to add tags/keywords to document properties. It worked but didn't updated the file in windows. It only works once you open File>Document Properties and click OK to confirm changes and resave. The meta data is being written differently with VBA...
xml:lang="x-default"
compared to using the Document Properties dialog.
xml:lang="en"
For anyone in the future, here's the answer that Eskimo found. You have to set the language for the string.