CorelDraw VBA添加文件标签无法同步至Windows的技术问询
CorelDraw VBA 关键词同步至Windows文件属性问题
问题概述
为方便文件库检索,编写了自定义「另存为」宏,尝试通过ActiveDocument.Metadata.Keywords = Tags.Value为文件添加标签/关键词,但存在以下问题:
- 设置后仅在CorelDraw的「文件>文档属性」内可见,Windows文件属性中无对应标签
- 必须手动打开文档属性对话框点击确认并重新保存,标签才会同步至Windows
原因分析
经论坛用户分析,VBA写入metadata.xml时使用xml:lang="x-default",而通过文档属性手动设置时使用xml:lang="en",手动修改该属性后Windows可识别标签。
当前宏代码
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 & "\" '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
需求
寻求正确的VBA实现方法,确保关键词能直接同步至Windows文件属性,无需手动操作文档属性对话框。
内容的提问来源于stack exchange,提问作者Jamie
相关产品推荐
相关产品推荐

