Char Char Char Char

R

Rachel

Hi,
I tried running the following macro from Cindy Meister, changing the Heading
2 Char to be Char Char Char Char etc. as in my document. For some reason, it
did not work. It would not accept the Set styl =
doc.Styles.Add(Name:="Style1") line and I did not know how to debug it. Does
there have to be a style called Style1 in order for it to work? Do I need to
create one? It did not create one itself as far as I could tell.
Regards,
Rachel (see macro below)

Sub DeleteHeading2Char()
Dim styl As Word.Style, doc As Word.Document
Set doc = ActiveDocument
Set styl = doc.Styles.Add(Name:="Style1")
On Error Resume Next
doc.Styles("Heading 2 Char").LinkStyle = styl
styl.Delete
End Sub
 
S

Stefan Blom

The doc.Styles.Add(Name:="Style1") line creates a style named Style1.
If such a style already exists (which would be the case if it was
created from the user interface, or if you are running the code more
than once) you'd get an error message.

To reference an existing style, you could use doc.Styles("Style1")
instead.

--
Stefan Blom
Microsoft Word MVP


in message
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top