How to avoiding "rng.select" in a macro ?

A

andreas

Hello,

Allow me to quickly portray my problem. My figure captions are
formatted like this (example):

Figure 1-1: (inserted tabstop) The difference between ...
- The whole paragraph is formatted with a custom caption style
- The beginning up to the caption description itself (Figure
1-1:inserted tabstop) is formatted with a custom character style

Now I would like to reset the character style formatting of the
tabstop to the underlying custom caption style by using below macro.

It is working fine but I would like to avoid the "rng.select" line
because one should use ranges without having to select them, am I
right? How can I achieve this?


Sub ResetTabFormat()

Dim para As Word.Paragraph
Dim rng As Word.Range

Application.ScreenUpdating = False
For Each para In ActiveDocument.Paragraphs
If para.Range.Style.NameLocal = "custom_caption_style" Then

Set rng = para.Range

rng.StartOf unit:=wdParagraph
With rng
.MoveUntil Cset:=vbTab, Count:=wdForward
.MoveEnd unit:=wdCharacter, Count:=1
.Select 'How do I have to rewrite the macro not using "with
rng.select"
End With

rng.Font.Reset

End If
Next para

End Sub

Help is appreciated. Thank you in advance

Regards,

Andreas
 
J

Jonathan West

You only need to Select if you subsequently do something with the Selection
object. from the code that you have shown us, you don't. Just delete that
line.
 

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