Pasting unformatted text into Open Office documents
Facts - Other software technologies
Thursday, 13 May 2010 18:55

This page applies to OpenOffice 3.

When pasting text in Open Office or Microsoft Word with Ctrl-V the pasted text appears formatted by default. This is almost never what I want, almost always I would like to paste unformatted text. With Ctrl-Shift-V one can do a "Paste Special" which pops up a menu with options and one of these options is a formatted paste.

Still typing Ctrl-Shift-V instead of Ctrl-V and selecting formatted text from the menu and finally pressing return is too much work for me. So I searched the internet for a solution for easy pasting unformatted text into OpenOffice documents.

The solution is simply defining a macro function, not in your document but one that is accessible from any of your OpenOffice documents and then attaching this function to Ctrl-V. By default Ctrl-Shift-V is attached to the standard Paste Special function allowing for the formatted text paste as well. So by typing Ctrl-Shift-V you can still paste formatted text.

On a forum I found the following Open Office macro function for pasting unformatted text :

sub PasteSpecial 
rem ---------------------------------------------------------------------- 
rem define variables 
dim document   as object 
dim dispatcher as object 
rem ---------------------------------------------------------------------- 
rem get access to the document 
document   = ThisComponent.CurrentController.Frame 
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") 

rem ---------------------------------------------------------------------- 
dim args1(0) as new com.sun.star.beans.PropertyValue 
args1(0).Name = "SelectedFormat" 
args1(0).Value = 1 

dispatcher.executeDispatch(document, ".uno:ClipboardFormatItems", "", 0, args1()) 

end sub

This macro can be defined by choosing Tools, Macros, Administer Macro's, OpenOffice Basic. Then go to My Macro's, Default or Standard and choose New and add your macro to the existing macro's in the pop up window.

This macro can be attached to a key via the menu Tools or Extra, Customize and then go to the Keyboard tab and bind Ctrl-V to the macro function.