Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
DSO and Custom Properties
I assign a custom property to a file (a.xls); the property name is "Balance"
and its value is 123.45 In another file the following code does retrieve the 123.45: Sub surface() Dim FileName As String Dim DSO As DSOFile.OleDocumentProperties Set DSO = New DSOFile.OleDocumentProperties FileName = "C:\a.xls" DSO.Open sfilename:=FileName MsgBox (DSO.CustomProperties.Count) MsgBox (DSO.CustomProperties.Item("Balance").Value) DSO.Close End Sub I would like to get the value without knowing the name; both: MsgBox (DSO.CustomProperties.Item(1).Value) and MsgBox (DSO.CustomProperties.Item(1).Name) fail. How can i get the name of the first custom property?? -- Gary''s Student - gsnu200723 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
DSO and Custom Properties
The following works fine for me using DSO 2.0.
Dim DSO As DSOFile.OleDocumentProperties Dim CustProps As DSOFile.CustomProperties Set DSO = New DSOFile.OleDocumentProperties DSO.Open "Book5.xls", True, dsoOptionDefault Set CustProps = DSO.CustomProperties Debug.Print CustProps(1).Name, CustProps(1).Value DSO.Close -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting LLC www.cpearson.com (email on the web site) "Gary''s Student" wrote in message ... I assign a custom property to a file (a.xls); the property name is "Balance" and its value is 123.45 In another file the following code does retrieve the 123.45: Sub surface() Dim FileName As String Dim DSO As DSOFile.OleDocumentProperties Set DSO = New DSOFile.OleDocumentProperties FileName = "C:\a.xls" DSO.Open sfilename:=FileName MsgBox (DSO.CustomProperties.Count) MsgBox (DSO.CustomProperties.Item("Balance").Value) DSO.Close End Sub I would like to get the value without knowing the name; both: MsgBox (DSO.CustomProperties.Item(1).Value) and MsgBox (DSO.CustomProperties.Item(1).Name) fail. How can i get the name of the first custom property?? -- Gary''s Student - gsnu200723 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
DSO and Custom Properties
Thank you Chip.
To get it to work I had to add a second custom property, however. I wondow why? -- Gary''s Student - gsnu200723 "Chip Pearson" wrote: The following works fine for me using DSO 2.0. Dim DSO As DSOFile.OleDocumentProperties Dim CustProps As DSOFile.CustomProperties Set DSO = New DSOFile.OleDocumentProperties DSO.Open "Book5.xls", True, dsoOptionDefault Set CustProps = DSO.CustomProperties Debug.Print CustProps(1).Name, CustProps(1).Value DSO.Close -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting LLC www.cpearson.com (email on the web site) "Gary''s Student" wrote in message ... I assign a custom property to a file (a.xls); the property name is "Balance" and its value is 123.45 In another file the following code does retrieve the 123.45: Sub surface() Dim FileName As String Dim DSO As DSOFile.OleDocumentProperties Set DSO = New DSOFile.OleDocumentProperties FileName = "C:\a.xls" DSO.Open sfilename:=FileName MsgBox (DSO.CustomProperties.Count) MsgBox (DSO.CustomProperties.Item("Balance").Value) DSO.Close End Sub I would like to get the value without knowing the name; both: MsgBox (DSO.CustomProperties.Item(1).Value) and MsgBox (DSO.CustomProperties.Item(1).Name) fail. How can i get the name of the first custom property?? -- Gary''s Student - gsnu200723 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
DSO and Custom Properties
"Gary''s Student" wrote:
Thank you Chip. To get it to work I had to add a second custom property, however. I wondow why? Looks like you need to use a zero based index Dim DSO As DSOFile.OleDocumentProperties Dim CustProps As DSOFile.CustomProperties Set DSO = New DSOFile.OleDocumentProperties DSO.Open "Book1.xls", True, dsoOptionDefault Set CustProps = DSO.CustomProperties If CustProps.Count = 1 Then Debug.Print CustProps(0).Name, CustProps(0).Value End If DSO.Close -- urkec |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
DSO and Custom Properties
Thanks for responding. You are correct.
-- Gary''s Student - gsnu200723 "urkec" wrote: "Gary''s Student" wrote: Thank you Chip. To get it to work I had to add a second custom property, however. I wondow why? Looks like you need to use a zero based index Dim DSO As DSOFile.OleDocumentProperties Dim CustProps As DSOFile.CustomProperties Set DSO = New DSOFile.OleDocumentProperties DSO.Open "Book1.xls", True, dsoOptionDefault Set CustProps = DSO.CustomProperties If CustProps.Count = 1 Then Debug.Print CustProps(0).Name, CustProps(0).Value End If DSO.Close -- urkec |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Custom File Properties | Excel Discussion (Misc queries) | |||
Custom properties for worksheets | Excel Programming | |||
Custom File Properties | Excel Discussion (Misc queries) | |||
Worksheet Custom Properties | Excel Programming | |||
Custom Properties | Excel Programming |