Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Custom property
Joerg,
I added the code as macro to my personal.xls and it worked - it added the property to the active workbook. msoPropertyTypeNumber value is 1. "Joerg" wrote: 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 |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Custom property
Hmmm... I'm stuck. The code works indeed from Personal.xls when I define
msoPropertyTypeNumber =1, but why do I have to (re)define a built- in constant? Thanks anyway for your help. Joerg "Vergel Adriano" wrote in message ... Joerg, I added the code as macro to my personal.xls and it worked - it added the property to the active workbook. msoPropertyTypeNumber value is 1. "Joerg" wrote: 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 |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Custom property
Joerg,
Only thing I think is you do not have reference to the Office xx Object Library in that WB as it is an Office enum, not Excel. Check the references. NickHK "Joerg" wrote in message ... Hmmm... I'm stuck. The code works indeed from Personal.xls when I define msoPropertyTypeNumber =1, but why do I have to (re)define a built- in constant? Thanks anyway for your help. Joerg "Vergel Adriano" wrote in message ... Joerg, I added the code as macro to my personal.xls and it worked - it added the property to the active workbook. msoPropertyTypeNumber value is 1. "Joerg" wrote: 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 |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Adding Custom property
Bingo! Thanks NickHK! My Personal.xls is a very old friend and obviously not
quite up-to-date. But now that I know the cause I keep the declaration of msoPropertyTypeNumber to make my code backward compatible. Cheers, Joerg Mochikun "NickHK" wrote in message ... Joerg, Only thing I think is you do not have reference to the Office xx Object Library in that WB as it is an Office enum, not Excel. Check the references. NickHK "Joerg" wrote in message ... Hmmm... I'm stuck. The code works indeed from Personal.xls when I define msoPropertyTypeNumber =1, but why do I have to (re)define a built- in constant? Thanks anyway for your help. Joerg "Vergel Adriano" wrote in message ... Joerg, I added the code as macro to my personal.xls and it worked - it added the property to the active workbook. msoPropertyTypeNumber value is 1. "Joerg" wrote: 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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Adding custom list and text boxes to the custom tool bar from Excel C API | Excel Discussion (Misc queries) | |||
Adding custom property pages to Tools | Options | Excel Programming | |||
Can you link a custom property to an Excel custom header text? | Setting up and Configuration of Excel | |||
"See" Custom Property | New Users to Excel | |||
Adding Custom Property | Excel Programming |