Conditional formatting can only be used to apply formats to the entire layout object. It can't be used to apply formatting to just a part of the object such as a selected word within the text field.
Perform Find/Replace can be used to highlight the first instance of the word, but I don't see an option that will highlight all instances of the word.
It is possible to create a looping script, recursive custom function (requires FileMaker Advanced to create), or a recursive calculation that will highlight all instances of a selected word in a text field.
Thanks. I have struggled three days with this. I am thinking of purchasing Filemaker Advanced. I want to work with documentation that is already created, in Work, PDF, and Excel. I want to pull th information into filemaker and break it up into sections. I hope this program will work for me. Thanks for the help...
FileMaker should be able to do this and comes with a fairly decent set of text functions that may help you accomplish this. FileMaker advanced offers three very valuable features not found in regular FileMaker: The ability to create custom functions such as a recursive "highlight text" function, A script debugger with data viewer that can save one hours of frustration when a scritp doesn't perform as expected and Database Design Reports that can be searched and analyzed for problems due to "broken" references to scripts, fields, tables etc.
Here's a custom function for applying a user specified style to every instance of a word in a block of text:
// WordHighlight ( Paragraph ; Word ; style )
// Returns text in Paragraph with every instance of Word having the style specified in style applied to it.
Let ( [ TheWord = LeftWords ( Paragraph ; 1 ) ;
StartText = Left ( Paragraph ; Position ( Paragraph ; TheWord ; 1 ; 1 ) + Length ( TheWord ) ) ;
RemainText = Right ( Paragraph ; Length ( Paragraph ) - Length ( StartText ) ) ] ;
Case ( IsEmpty ( Paragraph ) ; Paragraph ;
TheWord = Word ; TextStyleAdd ( StartText ; style ) & WordHighlight ( RemainText ; Word ; style ) ;
/* else */ StartText & WordHighlight ( RemainText ; Word ; style )
) // case
) // let
Here's a looping script that does much the same thing: It places the styled text in a separate field so you can compare the original to the styled text, but a small change in the last line would make it apply the style to original field, though in that case you might want to add a step to apply textformatRemove to this field first if you don't want repeated runs of this script to leave text bolded by a previous run still in bold face.
Set Variable [ $I; Value:1 ]
Set Variable [ $Word; Value:$Word + 1 ]
If [ MiddleWords ( WordHighlighter::Paragraph ; $Word ; 1 ) = WordHighlighter::Word ]
Set Variable [ $Paragraph;
Value:$Paragraph & TextStyleAdd ( Middle ( WordHighlighter::Paragraph;
$I ; Position ( WordHighlighter::Paragraph ; WordHighlighter::Word ; $I ; 1 ) + Length ( WordHighlighter::Word ) - $I + 1 ) ; Bold ) ]
Set Variable [ $Paragraph; Value:Let ( word = MiddleWords ( WordHighlighter::Paragraph ; $Word ; 1 ) ; $Paragraph &
Middle ( WordHighlighter::Paragraph; $I ; Position ( WordHighlighter::Paragraph ; word ; $I ; 1 ) + Length ( Word ) - $I + 1 ) ) ]
Set Variable [ $I; Value:Let ( word = MiddleWords ( WordHighlighter::Paragraph ; $Word ; 1 ) ;
Position ( WordHighlighter::Paragraph ; Word ; $I ; 1 ) + Length ( Word ) ) + 1 ]
Exit Loop If [ $Word ≥ WordCount ( WordHighlighter::Paragraph ) ]
Set Field [ WordHighlighter::Paragraph 2; $Paragraph ]
Thanks a million for the scripts... Will I be able to use these in FMP or do I have to have FMP Advanced... This is great. I did not expect this kind of help. Thanks again.... I am assuming you name is Phil!!!
The looping script will work with any version--that's why I included it.
The custom function requires FileMaker Advanced to install. (You can use a custom function with regular FileMaker once you've used advanced to either create or import it.) If you have advanced, the custom function will save you set up time as you can copy and paste the text from my post into your custom function dialog.
I just purchased FMP Advanced.... Thanks