Properties

Properties

Anonymous
Not applicable
311 Views
2 Replies
Message 1 of 3

Properties

Anonymous
Not applicable
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 :-((
0 Likes
312 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
I had a similar problem once.
It was the Thumbnail property which returns an IPictureDisp object. Just a thought.

Upon a closer look though I see that in the first example, the line...If StrComp("Issue", oProp.Name) = 0 Then
,skips the code that would call for the oProp.value. So the first example doesn't have errors because you aren't trying to access the oProp.value unless the oProp.Name is "Issue" Message was edited by: scarmart
0 Likes
Message 3 of 3

Anonymous
Not applicable
in the example that fails you are not taking into consideration cases that
don't have a value that is displayable [i.e. Part Icon]. i think that error
checking would be the answer.


wrote in message news:5820935@discussion.autodesk.com...
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 :-((
0 Likes