Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Refer to customproperty by name?

Hi everybody,

is there something wrong with this code
or is something wrong with Excel?

'ActiveSheet.CustomProperties.Add Name:="x", Value:=1 ' ok

MsgBox ActiveSheet.CustomProperties("x").Value ' Type mismatch
MsgBox ActiveSheet.CustomProperties(1).Value ' ok

In Word I can refer to a customdocumentproperty by name.
MsgBox ActiveDocument.CustomDocumentProperties("x").Value ' ok

--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000 (german versions)



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Refer to customproperty by name?

You can do the same in Excel with CustomDOCUMENTProperties

ActiveWorkbook.CustomDocumentProperties.Add Name:="x", _
LinkToContent:=False, Type:=msoPropertyTypeNumber, Value:=1

MsgBox ActiveWorkbook.CustomDocumentProperties("x").Value ' Type mismatch
MsgBox ActiveWorkbook.CustomDocumentProperties(1).Value ' ok



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Helmut Weber" wrote in message
...
Hi everybody,

is there something wrong with this code
or is something wrong with Excel?

'ActiveSheet.CustomProperties.Add Name:="x", Value:=1 ' ok

MsgBox ActiveSheet.CustomProperties("x").Value ' Type mismatch
MsgBox ActiveSheet.CustomProperties(1).Value ' ok

In Word I can refer to a customdocumentproperty by name.
MsgBox ActiveDocument.CustomDocumentProperties("x").Value ' ok

--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000 (german versions)





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Refer to customproperty by name?

Helmut,
Not sure how you managed to get the .Add statement to work, as there are a
few errors in that code :
- It is the "CustomDocumentProperties" collection.
- The collection is part of the Workbook, not Worksheet object.

See here for some help :
http://www.cpearson.com/excel/docprop.htm

NickHK

"Helmut Weber" ...
Hi everybody,

is there something wrong with this code
or is something wrong with Excel?

'ActiveSheet.CustomProperties.Add Name:="x", Value:=1 ' ok

MsgBox ActiveSheet.CustomProperties("x").Value ' Type mismatch
MsgBox ActiveSheet.CustomProperties(1).Value ' ok

In Word I can refer to a customdocumentproperty by name.
MsgBox ActiveDocument.CustomDocumentProperties("x").Value ' ok

--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000 (german versions)





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Refer to customproperty by name?

He is using CustomProperties Nick, not CustomDocumentProperties, wherein
lies his problem.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"NickHK" wrote in message
...
Helmut,
Not sure how you managed to get the .Add statement to work, as there are a
few errors in that code :
- It is the "CustomDocumentProperties" collection.
- The collection is part of the Workbook, not Worksheet object.

See here for some help :
http://www.cpearson.com/excel/docprop.htm

NickHK

"Helmut Weber"

...
Hi everybody,

is there something wrong with this code
or is something wrong with Excel?

'ActiveSheet.CustomProperties.Add Name:="x", Value:=1 ' ok

MsgBox ActiveSheet.CustomProperties("x").Value ' Type mismatch
MsgBox ActiveSheet.CustomProperties(1).Value ' ok

In Word I can refer to a customdocumentproperty by name.
MsgBox ActiveDocument.CustomDocumentProperties("x").Value ' ok

--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000 (german versions)







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default Refer to customproperty by name?

Hi everybody,

what is confusing me is that there is without any doubt
not only a CustomDocumentProperties collection,
but a CustomProperties collection as well.

Sub Test00023()
Dim oSht As Worksheet
Dim oPrt As Property
Dim bFnd As Boolean
Dim lPrt As Long
Set oSht = ActiveSheet
bFnd = False
For lPrt = 1 To oSht.CustomProperties.Count
If oSht.CustomProperties(lPrt).name = "x" Then
bFnd = True
End If
Next
If bFnd = False Then
ActiveSheet.CustomProperties.Add name:="x", Value:=1
End If
On Error Resume Next
MsgBox ActiveSheet.CustomProperties("x").Value ' Type mismatch
If Err.Number 0 Then
MsgBox Err.Number & " = " & Err.Description
End If
MsgBox ActiveSheet.CustomProperties(1).Value ' ok
End Sub

- It is the "CustomDocumentProperties" collection.
- The collection is part of the Workbook, not Worksheet object.


Whereas the CustomProperties collection seems to be
a part of the worksheet object.

I was wondering, whether a CustomProperty
can, seemably, not be addressed by name,
and what a name at all would be good for, then.

Not that I couldn't work around it, no problem at all.

I was just curious about an apparently
faulty design of the CustomProperties collection.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Refer to customproperty by name?

Helmut,
Whilst Help does mention the DocumentProperties collection, I find nothing
on the CustomProperties collection, for XL2K.
You code will not compile on my version, as I now see this is a XL2003
feature designed to work with XML :
http://msdn.microsoft.com/library/en...asp?frame=true

So I guess Item can only return the Property value by Index, not by
key/name.
As I don't have this version of Excel, I can you much.

NickHK

"Helmut Weber" wrote in message
...
Hi everybody,

what is confusing me is that there is without any doubt
not only a CustomDocumentProperties collection,
but a CustomProperties collection as well.

Sub Test00023()
Dim oSht As Worksheet
Dim oPrt As Property
Dim bFnd As Boolean
Dim lPrt As Long
Set oSht = ActiveSheet
bFnd = False
For lPrt = 1 To oSht.CustomProperties.Count
If oSht.CustomProperties(lPrt).name = "x" Then
bFnd = True
End If
Next
If bFnd = False Then
ActiveSheet.CustomProperties.Add name:="x", Value:=1
End If
On Error Resume Next
MsgBox ActiveSheet.CustomProperties("x").Value ' Type mismatch
If Err.Number 0 Then
MsgBox Err.Number & " = " & Err.Description
End If
MsgBox ActiveSheet.CustomProperties(1).Value ' ok
End Sub

- It is the "CustomDocumentProperties" collection.
- The collection is part of the Workbook, not Worksheet object.


Whereas the CustomProperties collection seems to be
a part of the worksheet object.

I was wondering, whether a CustomProperty
can, seemably, not be addressed by name,
and what a name at all would be good for, then.

Not that I couldn't work around it, no problem at all.

I was just curious about an apparently
faulty design of the CustomProperties collection.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Refer to customproperty by name?

It's in XP too Nick.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"NickHK" wrote in message
...
Helmut,
Whilst Help does mention the DocumentProperties collection, I find nothing
on the CustomProperties collection, for XL2K.
You code will not compile on my version, as I now see this is a XL2003
feature designed to work with XML :

http://msdn.microsoft.com/library/en...asp?frame=true

So I guess Item can only return the Property value by Index, not by
key/name.
As I don't have this version of Excel, I can you much.

NickHK

"Helmut Weber" wrote in message
...
Hi everybody,

what is confusing me is that there is without any doubt
not only a CustomDocumentProperties collection,
but a CustomProperties collection as well.

Sub Test00023()
Dim oSht As Worksheet
Dim oPrt As Property
Dim bFnd As Boolean
Dim lPrt As Long
Set oSht = ActiveSheet
bFnd = False
For lPrt = 1 To oSht.CustomProperties.Count
If oSht.CustomProperties(lPrt).name = "x" Then
bFnd = True
End If
Next
If bFnd = False Then
ActiveSheet.CustomProperties.Add name:="x", Value:=1
End If
On Error Resume Next
MsgBox ActiveSheet.CustomProperties("x").Value ' Type mismatch
If Err.Number 0 Then
MsgBox Err.Number & " = " & Err.Description
End If
MsgBox ActiveSheet.CustomProperties(1).Value ' ok
End Sub

- It is the "CustomDocumentProperties" collection.
- The collection is part of the Workbook, not Worksheet object.


Whereas the CustomProperties collection seems to be
a part of the worksheet object.

I was wondering, whether a CustomProperty
can, seemably, not be addressed by name,
and what a name at all would be good for, then.

Not that I couldn't work around it, no problem at all.

I was just curious about an apparently
faulty design of the CustomProperties collection.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"










Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I refer to a row Mark F[_2_] New Users to Excel 2 July 7th 11 05:29 PM
How to refer a name in VBA clara Excel Discussion (Misc queries) 4 June 26th 08 12:27 AM
Refer to value strikeuk Excel Discussion (Misc queries) 8 May 17th 06 08:42 AM
refer indirectly to Name Hershmab Excel Worksheet Functions 5 March 24th 06 04:30 PM
refer JE McGimpsey Excel Discussion (Misc queries) 2 November 28th 05 06:55 PM


All times are GMT +1. The time now is 10:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"