FileMaker Addict Has Moved!

FileMaker Addict can now be found here: http://www.filemakeraddict.com




Friday, January 04, 2008

Tip: Pasting Text Without Style

Have you ever copied text from an application (such as a Web browser) and pasted it into a field in a FileMaker database, only to find that the text was pasted in with the an undesirable style (color, font, size, etc)? Sometimes the styled text is ok. But if you're pasting the text into a field that you use for doing things like printing reports or labels, the styled text can cause you problems.

Removing the style from the pasted text can be very inconvenient. You can do it manually, and start by making the text "plain text" (via the Format / Style / Plain Text menu option). But that doesn't change the font, size, or color of the text. So you have to continue working on the text in order to clean it up.

Another option is to first paste the text into a text editor. (I use TextWranger by Bare Bones Software and highly recommend it!) This removes all of the style and formatting of the text. You then copy the text, and paste it into FileMaker. This is a roundabout way to clean up the text.

Another trick is to paste the text into a container field in the FileMaker database. This will strip out the style and formatting, and leave you with nice, clean, unformatted text. You then copy the container contents (just click on the container and press Command-C), and paste it into the text field. This is very similar to the text editor method that I mentioned earlier, but at least you won't have to use another application to strip the formatting.

Here's the best method I've found for cleaning up the formatted text: When you paste the text into the FileMaker field, immediately press Command-Z. Command-Z is typically used to undo something, and you'd think that doing this after pasting text into a field would undo the paste operation. But that's not what it does in this case. Instead, it leaves the pasted text in the field, but removes the formatting for you! (Note that pressing Command-Z a second time will undo the paste altogether!)

Got a tip or trick that you'd like to share with other FileMaker Addict readers? Are you a FileMaker Addict that is ready for your 15 minutes of fame? Email me and let me know!

-- Tim

8 comments:

Graham said...

An even better way is the Paste Text Only command -- Command-Option-V. It will paste the text without formatting. You can also use an auto-enter calc to strip the formatting when you exit the field.

Anonymous said...

Tim this is perfect! Thanks!

Jack - Lincoln, NE said...

Hey Tim, Thanks for all the info. I think i have a great way around the pasting of formatted text. Make the field Auto Enter a calculated value and apply this nested formatting function:

TextSize (TextColor (TextFont (MYFIELDNAME ; "MyDefault" ) ; RGB ( 0 ; 0 ; 0 ) ) ; 11 )

Where MYFIELDNAME is the name of the field. Leave "MyDefault" as is and set the default font in your FMP Preferences (Or implicitly specify the appropriate font). Users will also need to specify size (Mine is set to 11).

It is not as "global" in as far as this will have to be done for every field in which formatting would need to be removed from pasted text.

Jason said...

An even better way to set a field to auto remove style via auto-enter calculation...

Evaluate ( Quote ( field ) )

Anonymous said...

I had a situation where I was cleaning up data entered by another user and needed to remove the sloppy formatting, but did not want to prevent the ability to enter formatted text into the fields. I created a simple script "Remove Text Formatting" -- Cut[], Paste [Select;No style] -- and moved it to the top of my scripts menu so that it's assigned the keyboard shortcut Command + 1. Just select the text you want to strip of formatting, and then hit Command + 1. It's not as fast as preventing formatted text altogether, but it saves a few keystrokes if you're cleaning up text in fields where you do not want to disallow formatted text.

David R. Darrow said...

In Filemaker 7, Mac, using Command-Z once removes the pasting... I don't see how to get it to remove formatting.

Tim Dietrich said...

David --

If you're on a Mac, try this: Command-Option-Shift-V. I believe that more universally "pastes without style" and might work for you.

-- Tim

connectionfailure said...

What about TextFormatRemove(FIELD)

I also nest a Substitute() command

TextFormatRemove(Substitute(FIELD ; [replaceme;replacewiththis] ))

That way i can zap gremlins like spaces and other illegal characters at the same time.