Macro to change style based on style of current paragraph

B

Beth Brooks

Hi!

Though I've made a couple of attempts at this, I have yet to figure out how
to create a macro that does the following.

1. Determine the style of the paragraph in which the cursor is sitting.
2. Compare the style determined in step 1 to a short list of style names. If
the style = A, change the style of the paragraph in which the cursor is
sitting to A1;if the style = B, change to B1, and so on.
3. If the style is not equal to one that is on the list, return an error
message.

ANybody have something liek this I can look at or some suggestions about how
to create this macro?

Thanks!

Beth
 
D

Doug Robbins - Word MVP

If the list is not too long, you could use something like

Dim stylename As String
With Selection.Paragraphs(1)
stylename = .Style
If stylename = "A" Then
.Style = "A1"
ElseIf stylename = "B" Then
.Style = "B1"
Else
MsgBox "Style not in List"
End If
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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