Is there a macro to SELECT whatever words are in Italics? Nothing else?

I’ve been trying to make one, and have been making a terrible mess. I’ve found several somewhat similar macros here, but nothing that will actually do the job — and my efforts to customize them have resulted either in the macro blowing, or in nothing happening.

This is for LibreOffice Writer, by the way.

Hmm - Edit -> Find & Replace and using button Format at the bottom and selecting Style “Italic” does not fit your purpose (after using button Find All all italics are selected and if you close the Find & Replace dialog they keep being selected)? Checking option Including Styles will also find and select italics-styled text

Addition: For me it also worked to record a macro while performing the Find & Replace action (using LIbreOffice 6.3.2.2)

Thanks, but I already tried that. YES, it WORKS — until I close the document and try to run that macro on another document, and THEN it doesn’t work. I’ve been tinkering around for days trying to get it to work. I’ve tried editing the macro, but it either crashes or freezes when I do that (my programming skills are not good enough).

I tried posting my code, but got stopped by the 1000 character limit.

TL;DR — I need to add some “args” that will set the FONT POSTURE in ATTRIBUTES and show the selection, but then switch the attribute OFF (without deselecting anything on my screen), to stop it interfering with other macros.

No matter how much I tweak the code, I cannot seem to get it to set the font posture ONLY for the document I’m working on.

Actually, there is a way. However, what exactly you want to do with the italic words/expressions?

From Andrew Pitonyak’s book, you can find some answers.
.
–Little Example–

REM -----------------------------------------------------------------------------
Sub FindItalicExpressionsAndDoSomething(Optional pTextDoc as Object, pWord as String, pWholeWord as Boolean) as Variant

''' Parameters: Text Document, a Word, Whole Word ?
''' Example:
''' 	Sub Main()
''' 		oDoc = ThisComponent
''' 		Call FindItalicExpressionsAndDoSomething ( oDoc, "THE WORD YOU NEED TO FIND", True )
''' 	End Sub

Dim oSearchDesc as Object
Dim wordsFound as Object
Dim SearchAttributes(0) as New com.sun.star.beans.PropertyValue
	
	If isMissing(pTextDoc) then pTextDoc = ThisComponent
	
	oSearchDesc = pTextDoc.createSearchDescriptor()
	
	REM Descriptor properties
	With oSearchDesc
		.SearchStyles = True
		.searchCaseSensitive = False
		.SearchRegularExpression = True
		.SearchString = pWord
		.searchWords = pWholeWord
	End with
	
	REM The attributes to find
	SearchAttributes(0).Name = "CharPosture"
	SearchAttributes(0).Value =com.sun.star.awt.FontSlant.ITALIC
	
	REM Set de attributes to the Search Descriptor
	oSearchDesc.SetSearchAttributes( SearchAttributes() )
	
	wordsFound = pTextDoc.findFirst( oSearchDesc )
	
	REM Here you need to define whatever you want to do.
	REM For example, get the word and change the CharWeight to normal
	REM However, if you need to replace the words for something else, you'll need to use the ReplaceDescriptor
	Do While Not IsNull( wordsFound )
		wordsFound.CharWeight = com.sun.star.awt.FontWeight.NORMAL
		wordsFound = pTextDoc.findNext( wordsFound.End, oSearchDesc)
	Loop

End Sub