Ask Your Question

Macro to change style of Heading 2 to hidden fails on CharHidden [closed]

asked 2016-01-15 15:55:06 +0200

SusanCragin gravatar image

updated 2016-01-15 15:56:20 +0200

Here's the macro. Why doesn't it work? A nearly identical macro using textbod works well.

Sub ToggleHeading2

oStyleFam = ThisComponent.StyleFamilies

ParaStyles =oStyleFam.getByName("ParagraphStyles")

Heading2 = ParaStyles.getByName("Heading 2")

If Heading2.CharHidden = True Then

Heading2.CharHidden = False


Heading2.CharHidden = True

End If

End Sub

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-03-10 22:19:50.781693


Very strange. The macro is working properly. Only, perhaps, should be replaced if-then-else on one line Heading2.CharHidden = not Heading2.CharHidden

JohnSUN gravatar imageJohnSUN ( 2016-01-15 16:21:45 +0200 )edit

Very, very strange. Your macro is more elegant than mine but produces the same error for me. And you say my macro works on your machine? (And a nearly identical macro works on my machine using TextBod instead of Heading2.) I have a macro poltergeist. It says that the first CharHidden is wrong.

SusanCragin gravatar imageSusanCragin ( 2016-01-15 17:41:04 +0200 )edit

On first start I also thought that the macro has not done anything. It just underline (dots) the text with style Header 2 . Then I realized that I did not turn off the display of non-printing characters... Oops!.. ;-)

JohnSUN gravatar imageJohnSUN ( 2016-01-15 18:44:59 +0200 )edit

2 Answers

Sort by » oldest newest most voted

answered 2016-01-15 19:09:39 +0200

JohnSUN gravatar image

Please try this - testOfMacro.odt

edit flag offensive delete link more

answered 2016-01-15 22:44:29 +0200

SusanCragin gravatar image

Your file's button did not work for me. ???? However, on my document I deleted all three modules I'd been testing, and re-entered them using your code, and leaving the names as Module 1, Module 2, and so on, and letting the command name itself from the code. And then I re-tested, and they work ?? Then I tried my code, and that seems to work also, provided I deleted the modules and created new ones. ???? I want to thank you for your help on behalf of myself and 25 romance novelists from New Hampshire. Susan Cragin

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-01-15 15:55:06 +0200

Seen: 75 times

Last updated: Jan 15 '16