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
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