' ' Released by www.ooextras.org under the LGPL license. ' See http://www.ooextras.org/license.txt for terms of license ' Original homepage: http://www.darwinwars.com/lunatic/bugs/oo_macros.html ' Sub transpose Dim oDocument, oDesktop as Object Dim oText as Object Dim oVCursor, oCursor As Object Dim sWombat as string ' the two following lines get the active document oDesktop = createUnoService("com.sun.star.frame.Desktop") oDocument= oDesktop.getCurrentComponent() oText = oDocument.Text ' after this, an obscure call gets the current cursor position ' but most cursor methods don't work with a view cursor oVCursor = oDocument.currentcontroller.getViewCursor() ' so now I create an invisible cursor under it, oCursor = oText.createTextCursorByRange(oVCursor.getstart()) ' grab the next character oCursor.goRight(1,TRUE) ' save a copy (no clipboard) sWombat = ocursor.getString() ' delete the original (seems to be no obvious delete method) ' obviously, what I wanted was a method to cut to the clipboard ' but this doesn't seem possible oCursor.setString("") ' next two lines move the invisible cursor oCursor.CollapseToStart() oCursor.goLeft(1,true) ' and now insert the cut character oText.insertString(oCursor.getStart(),sWombat,false) oVCursor.GoLeft(1,false) ' finally return the visible cursor whence it came End Sub