Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Adding Custom property

Hello World!

How can I add a custom property to the active workbook? Following code looks
OK to me, but produces a run-time error (invalid procedure call or
argument):

ActiveWorkbook.CustomDocumentProperties.Add Name:="NumberOfSheets",
_
LinkToContent:=False, _
Type:=msoPropertyTypeNumber, _
Value:=ActiveWorkbook.Sheets.Count

Thanks,

Joerg Mochikun


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Adding Custom property

Joerg,
Your code works for me in XL2002, but I have had difficulties sometimes
working with this collection.
Make sure this property does not already exist
Close the WB, open it again and try the code.

NickHK

"Joerg" wrote in message
...
Hello World!

How can I add a custom property to the active workbook? Following code

looks
OK to me, but produces a run-time error (invalid procedure call or
argument):

ActiveWorkbook.CustomDocumentProperties.Add

Name:="NumberOfSheets",
_
LinkToContent:=False, _
Type:=msoPropertyTypeNumber, _
Value:=ActiveWorkbook.Sheets.Count

Thanks,

Joerg Mochikun




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Adding Custom property

Thanks for your quick reply. Property doesn't exist. If created manually,
then using it (e.g.
ActiveWorkbook.CustomDocumentProperties("NumberOfS heets") =
ActiveWorkbook.Sheets.Count)
works fine. Just creating it with VBA is the problem. I'm using XL2003.

Joerg


"NickHK" wrote in message
...
Joerg,
Your code works for me in XL2002, but I have had difficulties sometimes
working with this collection.
Make sure this property does not already exist
Close the WB, open it again and try the code.

NickHK

"Joerg" wrote in message
...
Hello World!

How can I add a custom property to the active workbook? Following code

looks
OK to me, but produces a run-time error (invalid procedure call or
argument):

ActiveWorkbook.CustomDocumentProperties.Add

Name:="NumberOfSheets",
_
LinkToContent:=False, _
Type:=msoPropertyTypeNumber, _
Value:=ActiveWorkbook.Sheets.Count

Thanks,

Joerg Mochikun






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Adding Custom property

Not much of an answer, but, wanted to let you know that your code worked for
me as well. I have xl2003. The only problem I had was that it errors out
the second time I run it because the property already exists by then.


"Joerg" wrote:

Thanks for your quick reply. Property doesn't exist. If created manually,
then using it (e.g.
ActiveWorkbook.CustomDocumentProperties("NumberOfS heets") =
ActiveWorkbook.Sheets.Count)
works fine. Just creating it with VBA is the problem. I'm using XL2003.

Joerg


"NickHK" wrote in message
...
Joerg,
Your code works for me in XL2002, but I have had difficulties sometimes
working with this collection.
Make sure this property does not already exist
Close the WB, open it again and try the code.

NickHK

"Joerg" wrote in message
...
Hello World!

How can I add a custom property to the active workbook? Following code

looks
OK to me, but produces a run-time error (invalid procedure call or
argument):

ActiveWorkbook.CustomDocumentProperties.Add

Name:="NumberOfSheets",
_
LinkToContent:=False, _
Type:=msoPropertyTypeNumber, _
Value:=ActiveWorkbook.Sheets.Count

Thanks,

Joerg Mochikun







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Adding Custom property

Thanks. Could you then tell me the value for msoPropertyTypeNumber? When I
debug the code the value for msoPropertyTypeNumber is empty. Could explain
the error, but I found no value table in XL Help and therefore can't try to
change to an absolute value.

Joerg

"Vergel Adriano" wrote in message
...
Not much of an answer, but, wanted to let you know that your code worked

for
me as well. I have xl2003. The only problem I had was that it errors out
the second time I run it because the property already exists by then.


"Joerg" wrote:

Thanks for your quick reply. Property doesn't exist. If created

manually,
then using it (e.g.
ActiveWorkbook.CustomDocumentProperties("NumberOfS heets") =
ActiveWorkbook.Sheets.Count)
works fine. Just creating it with VBA is the problem. I'm using XL2003.

Joerg


"NickHK" wrote in message
...
Joerg,
Your code works for me in XL2002, but I have had difficulties

sometimes
working with this collection.
Make sure this property does not already exist
Close the WB, open it again and try the code.

NickHK

"Joerg" wrote in message
...
Hello World!

How can I add a custom property to the active workbook? Following

code
looks
OK to me, but produces a run-time error (invalid procedure call or
argument):

ActiveWorkbook.CustomDocumentProperties.Add
Name:="NumberOfSheets",
_
LinkToContent:=False, _
Type:=msoPropertyTypeNumber, _
Value:=ActiveWorkbook.Sheets.Count

Thanks,

Joerg Mochikun











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default Adding Custom property

Just want to let you know that the code works fine when the macro is
included in the workbook where the custom property is to be craeted.
However I try to run it from my Personal.xls, so that I can add the property
to any (active) workbook. This attempt failed so far...

Joerg

"Joerg" wrote in message
...
Thanks. Could you then tell me the value for msoPropertyTypeNumber? When I
debug the code the value for msoPropertyTypeNumber is empty. Could explain
the error, but I found no value table in XL Help and therefore can't try

to
change to an absolute value.

Joerg

"Vergel Adriano" wrote in

message
...
Not much of an answer, but, wanted to let you know that your code worked

for
me as well. I have xl2003. The only problem I had was that it errors

out
the second time I run it because the property already exists by then.


"Joerg" wrote:

Thanks for your quick reply. Property doesn't exist. If created

manually,
then using it (e.g.
ActiveWorkbook.CustomDocumentProperties("NumberOfS heets") =
ActiveWorkbook.Sheets.Count)
works fine. Just creating it with VBA is the problem. I'm using

XL2003.

Joerg


"NickHK" wrote in message
...
Joerg,
Your code works for me in XL2002, but I have had difficulties

sometimes
working with this collection.
Make sure this property does not already exist
Close the WB, open it again and try the code.

NickHK

"Joerg" wrote in message
...
Hello World!

How can I add a custom property to the active workbook? Following

code
looks
OK to me, but produces a run-time error (invalid procedure call or
argument):

ActiveWorkbook.CustomDocumentProperties.Add
Name:="NumberOfSheets",
_
LinkToContent:=False, _
Type:=msoPropertyTypeNumber, _
Value:=ActiveWorkbook.Sheets.Count

Thanks,

Joerg Mochikun











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
Adding custom list and text boxes to the custom tool bar from Excel C API Mousam Excel Discussion (Misc queries) 0 August 7th 07 09:19 AM
Adding custom property pages to Tools | Options [email protected] Excel Programming 1 September 4th 06 12:47 PM
Can you link a custom property to an Excel custom header text? LouErc Setting up and Configuration of Excel 0 November 8th 05 04:58 PM
"See" Custom Property zSplash New Users to Excel 0 May 6th 05 11:42 PM
Adding Custom Property Robin Patra Excel Programming 2 May 12th 04 08:30 AM


All times are GMT +1. The time now is 06:27 PM.

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

About Us

"It's about Microsoft Excel"