CustomDocumentProperties problem...
Jens,
It appears that when you used a LinkedSource, the documentproperties doesn't
actually hold the value (which makes sense), but picks it up from the
LinkedSource. When you look in properties, it looks up that value.
In your code, you need to do the same
Sub DisplayPropertyInfo(dp As DocumentProperty)
MsgBox "value = " & Range(dp.LinkSource).Value & Chr(13) & _
"type = " & dp.Type & Chr(13) & _
"name = " & dp.Name
End Sub
--
HTH
Bob Phillips
"Jens Meier" wrote in message
...
Hello ng!
I am having some trouble with a CustomDocumentProperty I try to define in
an
Excel workbook.
As the code is very simple, here I go.
The first worksheet contains two named ranges, called "testfeld1"
(contains
value: "5") and "testfeld2" (contains value: "hello world").
=====================
Private Sub TestCDP()
If ActiveWorkbook.CustomDocumentProperties.Count 0 Then
ActiveWorkbook.CustomDocumentProperties("CDP").Del ete
ActiveWorkbook.CustomDocumentProperties("CDP2").De lete
End If
ActiveWorkbook.CustomDocumentProperties.Add Name:="CDP", _
Type:=msoPropertyTypeNumber, _
LinkToContent:=True, LinkSource:="testfeld"
ActiveWorkbook.CustomDocumentProperties.Add Name:="CDP2", _
Type:=msoPropertyTypeString, _
LinkToContent:=True, LinkSource:="testfeld2"
DisplayPropertyInfo (ActiveWorkbook.CustomDocumentProperties("CDP"))
DisplayPropertyInfo (ActiveWorkbook.CustomDocumentProperties("CDP2"))
End Sub
Sub DisplayPropertyInfo(dp As DocumentProperty)
MsgBox "value = " & dp.Value & Chr(13) & _
"type = " & dp.Type & Chr(13) & _
"name = " & dp.Name
End Sub
=====================
As a result, I get the following values:
CDP = 0
CDP2 = ???????????????????????????????????????????????? ?????????????
However, if I access the CDPs via the menu (File/Properties), I can see
the
correct values etc.
Any guess what's wrong?
Thanks a lot!
Jens
|