Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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
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
Custom File Properties Ade Hodgetts Excel Discussion (Misc queries) 2 April 2nd 08 10:34 PM
Custom properties for worksheets Thelonious Monk Excel Programming 3 September 11th 06 03:00 AM
Custom File Properties jujuwillis Excel Discussion (Misc queries) 1 August 1st 05 04:18 PM
Worksheet Custom Properties Rich_z Excel Programming 6 June 29th 05 04:49 PM
Custom Properties DavidW[_2_] Excel Programming 9 July 1st 04 03:31 PM


All times are GMT +1. The time now is 05:14 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"