Here is my code so far:
Public Function add_Blackout() On Error GoTo add_Blackout_Error Dim oEnumerator As ElementEnumerator Set oEnumerator = ActiveModelReference.GetSelectedElements oEnumerator.BuildArrayFromContents oEnumerator.Reset Do While oEnumerator.MoveNext Dim oElement As Element, oTextElement As TextElement, oTextNodeElement As TextNodeElement Set oElement = oEnumerator.Current If oElement.IsTextElement Then Set oTextElement = oElement.AsTextElement With oTextElement .TextStyle.BackgroundFillColor = 255 .TextStyle.BorderColor = 255 .TextStyle.BorderAndBackgroundVisible = True .Redraw .Rewrite End With End If If oElement.IsTextNodeElement Then Set oTextNodeElement = oElement.AsTextNodeElement With oTextNodeElement . .AsComplexStringElement.AsTextElement.TextStyle.BackgroundFillColor = 255 .AsComplexStringElement.AsTextElement.TextStyle.BorderColor = 255 .AsComplexStringElement.AsTextElement.TextStyle.BorderAndBackgroundVisible = True .Redraw .Rewrite End With End If Loop add_Blackout_Error: If Err.Description = "" Then ' Do Nothing Else: MsgBox Err.Description End If End Function
Dim oEnumerator As ElementEnumerator Set oEnumerator = ActiveModelReference.GetSelectedElements oEnumerator.BuildArrayFromContents oEnumerator.Reset Do While oEnumerator.MoveNext Dim oElement As Element, oTextElement As TextElement, oTextNodeElement As TextNodeElement Set oElement = oEnumerator.Current If oElement.IsTextElement Then Set oTextElement = oElement.AsTextElement With oTextElement .TextStyle.BackgroundFillColor = 255 .TextStyle.BorderColor = 255 .TextStyle.BorderAndBackgroundVisible = True .Redraw .Rewrite End With End If If oElement.IsTextNodeElement Then Set oTextNodeElement = oElement.AsTextNodeElement With oTextNodeElement . .AsComplexStringElement.AsTextElement.TextStyle.BackgroundFillColor = 255 .AsComplexStringElement.AsTextElement.TextStyle.BorderColor = 255 .AsComplexStringElement.AsTextElement.TextStyle.BorderAndBackgroundVisible = True .Redraw .Rewrite End With End If Loop
If I have selected a large grouping of Text and run this code, it works for the TextElements, but not the TextNodeElements. All I want to do is change the Background Color of the selected elements. I know they are all TextElements or TextNodeElements, but I can't find the code necessary to affect the TextNode TextStyles... does anyone have any hints?
DONE!
I figured it out.
I have included my code at: Universal Text Blackout Toggle Switch
It's all just lines and dots right?Rev. Brian Scott O'keefe( www.randomblink.com )
Question...
I have to run the main toggler twice to get all selected text when the selected text contains mixed types. ( Multiline and Single Line Text Elements / Text Node Elements )
Does anyone have any idea why?
How are you activating this?
Can you step through with the debugger?
Charles (Chuck) Rheault CADD Manager
MDOT State Highway Administration