Is there a macro for Writer which can find italic text in a particular style?

Can someone point me to or provide a macro which can go through a Writer document and select all italic text in a particular named paragraph style?

Thanks,

Jon.

I’m not sure that I clearly understand your question

Sub RemoveItalic
Dim oSearch  As Variant	' Search Descriptor'
Dim oFound As Variant	' All Results of findAll'
Dim SrchAttributes(0) As New com.sun.star.beans.PropertyValue
Dim oFRange As Variant  ' One range with CharPosture=ITALIC'
Dim i&
	oSearch = ThisComponent.createSearchDescriptor()
	oSearch.SearchString = ".*"           'Regular expression. Match any text'
	oSearch.SearchRegularExpression=True  'Use regular expressions'
REM This is the attribute to find
	SrchAttributes(0).Name = "CharPosture"
	SrchAttributes(0).Value =com.sun.star.awt.FontSlant.ITALIC
	oSearch.SetSearchAttributes(SrchAttributes())
	oFound = ThisComponent.findAll(oSearch) 
	If not IsNull(oFound) Then
	For i = 0 To oFound.getCount()-1
	oFRange = oFound.getByIndex(i)
	oFRange.CharStyleName = "eItal"	' For example - set for Italic chars style with name eItal...'
	Next i
	EndIf
End Sub

@JohnSUN: just added some ‘singleQuotes’ for proper Code-Hightlighting

Sorry, I just didn’t have time to do it - have distracted here, in the office :frowning:

Many thanks for this What I need is to give italics a particular character style ONLY when they appear in a paragraph with a particular paragraph style. I’ve modified the macro to do this by adding an If statement

 if oFRange.ParaStyleName = "Sub1" Then
    oFRange.CharStyleName = "Sub + italic" 
 EndIf

which seems to do the trick. This macro will save me a great deal of work.

Jon.