On 2012-02-27, Bernhard Sander <off...@kein.spam> wrote:
> If VarGibts Then
Ich hab das für das vergleichbare Problem mit den Dokumenteigenschaften
so geloest:
Function customdocpropertyexists(name As String) As Boolean
Dim cdp As DocumentProperty
customdocpropertyexists = False
For Each cdp In ActiveDocument.CustomDocumentProperties
If
cdp.name = name Then
customdocpropertyexists = True
Exit Function
End If
Next cdp
End Function
Function customdocpropertyget(name As String) As Variant
Dim cdp As DocumentProperty
For Each cdp In ActiveDocument.CustomDocumentProperties
If
cdp.name = name Then
customdocpropertyget = cdp.value
Exit Function
End If
Next cdp
End Function
Sub customdocpropertyset(name As String, value As Variant)
Dim cdp As DocumentProperty
For Each cdp In ActiveDocument.CustomDocumentProperties
If
cdp.name = name Then
cdp.value = value
Exit Sub
End If
Next cdp
Select Case TypeName(value)
Case "Byte", "Integer", "Long"
ActiveDocument.CustomDocumentProperties.Add name:=name, _
LinkToContent:=False, value:=value, _
Type:=msoPropertyTypeNumber
Case "Single", "Double", "Currency", "Decimal"
ActiveDocument.CustomDocumentProperties.Add name:=name, _
LinkToContent:=False, value:=value, _
Type:=msoPropertyTypeFloat
Case "Date"
ActiveDocument.CustomDocumentProperties.Add name:=name, _
LinkToContent:=False, value:=value, _
Type:=msoPropertyTypeDate
Case "String"
ActiveDocument.CustomDocumentProperties.Add name:=name, _
LinkToContent:=False, value:=value, _
Type:=msoPropertyTypeString
Case "Boolean"
ActiveDocument.CustomDocumentProperties.Add name:=name, _
LinkToContent:=False, value:=value, _
Type:=msoPropertyTypeBoolean
End Select
End Sub
Sub customdocpropertydelete(name As String)
Dim cdp As DocumentProperty
For Each cdp In ActiveDocument.CustomDocumentProperties
If
cdp.name = name Then
cdp.Delete
Exit Sub
End If
Next cdp
End Sub
Einmal angelegt, beliebig nutzbar.