I found the above thread to open the document properties with vba, but I can't press enter or confirm the dialog box. I have to manually press the ok button for it to continue.Is there a better way of going about this?
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 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
Not sure if this helps but I use this one to change the "Author". Could try adding to it.
Sub ChangeDocAuthor() ActiveDocument.Metadata.Author = "John Doe"ActiveDocument.SaveEnd Sub
These both seem to work for me:
Sub keyword_stuff_1() ActiveDocument.Metadata.Keywords = "apple, banana, cherry, date" ActiveDocument.Save End Sub Sub keyword_stuff_2() ActiveDocument.Metadata.Keywords = "apple, banana, cherry, date" ActiveDocument.Dirty = True End Sub
The first one actually performs the save. The second one just marks the file "dirty" so that CorelDRAW knows that unsaved changes have been made.
So I placed those two lines after my save as code so it's saving twice. I checked the file and I don't see the tags.I made a separate sub with just those two lines and it's adding the keyword and saving the document, but I checked the file in Windows and the tags aren't there.Only after I open the document properties and press ok, that the file saves the tag.
OK, I'm now convinced that I don't understand this well!
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:
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:
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.
I don't know if that helps to get you any closer to a solution, but there you are!
I will also note here that I think I should probably have been using semicolons instead of commas in my examples.