View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jens Meier Jens Meier is offline
external usenet poster
 
Posts: 18
Default CustomDocumentProperties problem...

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