自定义文档属性空值? [英] Custom document properties Null value?

查看:95
本文介绍了自定义文档属性空值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将文档属性值设置为"Null"?

Is it possible to set document properties values at "Null"?

我制作了一个我想要的模板填写没有初始值的属性数据。

I have made a template that i want to fill with properties data which has no initial value.

不需要预填充

Sub ResetDocProperties()
  'built-in property
  Call WriteProp(sPropName:="Author", sValue:=Null)
  Call WriteProp(sPropName:="Subject", sValue:=Null)
  Call WriteProp(sPropName:="Company", sValue:=Null)

  'custom document property
  Call WriteProp(sPropName:="Datum", sValue:=Null, lType:=msoPropertyTypeDate)
  Call WriteProp(sPropName:="Referentie", sValue:=Null, lType:=msoPropertyTypeString)
  Call WriteProp(sPropName:="Status", sValue:=Null, lType:=msoPropertyTypeString)
  Call WriteProp(sPropName:="Klant", sValue:=Null, lType:=msoPropertyTypeFloat)
  Call WriteProp(sPropName:="Project", sValue:=Null, lType:=msoPropertyTypeFloat)
  Call WriteProp(sPropName:="Onderwerp", sValue:=Null, lType:=msoPropertyTypeString)
  Call WriteProp(sPropName:="Taal", sValue:=Null, lType:=msoPropertyTypeString)
End Sub

Public Sub WriteProp(sPropName As String, sValue As String, _
      Optional lType As Long = msoPropertyTypeString)

Dim bCustom As Boolean

  On Error GoTo ErrHandlerWriteProp
  ActiveDocument.BuiltInDocumentProperties(sPropName).Value = sValue
  Exit Sub

Proceed:
  bCustom = True

Custom:
  ActiveDocument.CustomDocumentProperties(sPropName).Value = sValue
  Exit Sub

AddProp:
  On Error Resume Next
  ActiveDocument.CustomDocumentProperties.Add Name:=sPropName, _
    LinkToContent:=False, Type:=lType, Value:=sValue

  If Err Then
    Debug.Print "The Property " & Chr(34) & _
     sPropName & Chr(34) & " couldn't be written, because " & _
     Chr(34) & sValue & Chr(34) & _
     " is not a valid value for the property type"
  End If

  Exit Sub

ErrHandlerWriteProp:
  Select Case Err
    Case Else
   Err.Clear
   If Not bCustom Then
     Resume Proceed
   Else
     Resume AddProp
   End If
  End Select

End Sub

推荐答案

我想出了一个简单的解决方法: - )

I figured out a simple work around :-)

代替 

sValue:=Null

我输入了

sValue:=""


这篇关于自定义文档属性空值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆