J
Jon Borel
Hi,
I have the following Word 2003 code to check the current cursor insertion
point (or selection) for the style. If the style is "Bold Word" then do
something, otherwise, if it is any other style, do something else. This code
runs automatically in the background through an application event procedure
class module.
The problem is if multiple paragraphs (of two or more styles) are selected
at any time (Say a Heading 1 paragraph followed by a Body Text paragraph) the
code errors out: "Object variable or With Block Variable not set." It seems
I need a way to turn off this IF THEN statement if more than one style is
currently selected. Can this be done?
If Selection.Type = wdSelectionIP Or _
Selection.Type = wdSelectionNormal Then
If Selection.Style = ActiveDocument.Styles("Bold Word") Then
Do This
Else
Do This
End If
End If
Thanks,
Jon
I have the following Word 2003 code to check the current cursor insertion
point (or selection) for the style. If the style is "Bold Word" then do
something, otherwise, if it is any other style, do something else. This code
runs automatically in the background through an application event procedure
class module.
The problem is if multiple paragraphs (of two or more styles) are selected
at any time (Say a Heading 1 paragraph followed by a Body Text paragraph) the
code errors out: "Object variable or With Block Variable not set." It seems
I need a way to turn off this IF THEN statement if more than one style is
currently selected. Can this be done?
If Selection.Type = wdSelectionIP Or _
Selection.Type = wdSelectionNormal Then
If Selection.Style = ActiveDocument.Styles("Bold Word") Then
Do This
Else
Do This
End If
End If
Thanks,
Jon