Message 1 of 3
Properties

Not applicable
01-15-2008
08:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm having a "senior moment" testing some code!!
This works :-
Public Sub iProp()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
Dim oPropSets As PropertySets
Set oPropSets = oDoc.PropertySets
Dim oPropSet As PropertySet
For Each oPropSet In oPropSets
Debug.Print "set: " & oPropSet.DisplayName
' Iterate through all the Properties in the current set.
Dim oProp As Property
For Each oProp In oPropSet
' Obtain the Name of the Property
Debug.Print "name: " & oProp.Name
If StrComp("Issue", oProp.Name) = 0 Then
Debug.Print "value: " & oProp.Value
End If
Debug.Print
Next
Next
End Sub
and this doesn't (runtime error 91) :-
Public Sub iProp()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
Dim oPropSets As PropertySets
Set oPropSets = oDoc.PropertySets
Dim oPropSet As PropertySet
For Each oPropSet In oPropSets
Debug.Print "set: " & oPropSet.DisplayName
' Iterate through all the Properties in the current set.
Dim oProp As Property
For Each oProp In oPropSet
' Obtain the Name of the Property
Debug.Print "name: " & oProp.Name
' Obtain the Value of the Property
Debug.Print "value: " & oProp.Value
Debug.Print
Next
Next
End Sub
Put a tired old man on the right track :-((
This works :-
Public Sub iProp()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
Dim oPropSets As PropertySets
Set oPropSets = oDoc.PropertySets
Dim oPropSet As PropertySet
For Each oPropSet In oPropSets
Debug.Print "set: " & oPropSet.DisplayName
' Iterate through all the Properties in the current set.
Dim oProp As Property
For Each oProp In oPropSet
' Obtain the Name of the Property
Debug.Print "name: " & oProp.Name
If StrComp("Issue", oProp.Name) = 0 Then
Debug.Print "value: " & oProp.Value
End If
Debug.Print
Next
Next
End Sub
and this doesn't (runtime error 91) :-
Public Sub iProp()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
Dim oPropSets As PropertySets
Set oPropSets = oDoc.PropertySets
Dim oPropSet As PropertySet
For Each oPropSet In oPropSets
Debug.Print "set: " & oPropSet.DisplayName
' Iterate through all the Properties in the current set.
Dim oProp As Property
For Each oProp In oPropSet
' Obtain the Name of the Property
Debug.Print "name: " & oProp.Name
' Obtain the Value of the Property
Debug.Print "value: " & oProp.Value
Debug.Print
Next
Next
End Sub
Put a tired old man on the right track :-((