我在使用Word 2010中的VBA设置文档属性时遇到了一些问题.
我有一个包含几个Heading 1部分的文档,我使用宏来提取所选部分(及其内容)并将其粘贴到新文档中.
这部分工作正常,但最后我需要设置几个文档属性,但没有设置它们.
我正在尝试设置内置和自定义属性,但出于这个问题的目的,我想设置标题,主题和类别.
我已经创建了一个函数来设置我想要的属性(如下所示),并且VBA没有抛出任何错误(即使我删除了函数中的错误处理).
有谁知道我做错了什么?
以下是该功能应该做什么的简要总结,但如果您发现更容易检查 - 下面的完整功能 -
default属性
PropertyTypeUsed变量设置为defaultcustom财产
PropertyTypeUsed变量设置为customPropertyTypeUsed变量设置为customdefault应该设置一个属性
custom应该设置一个属性
Function UpdateDocumentProperty(ByRef doc As Document, _
ByVal propertyName As String, _
ByVal propertyValue As Variant, _
Optional ByVal propertyType As Office.MsoDocProperties = 4)
'** Set …Run Code Online (Sandbox Code Playgroud)