Hi
I have small problem . I'd like copy (get) text between two strings in document. This text should by insert at the end of second string.
This is my code.
<el:strony> and </el:strony> are this two string. I what get formated text between <el:strony> and </el:strony> and insert at the and of </el:strony> string.
How can i do this?
Edit: Topic moved from Writer forum to Macros and UNO API
Last edited by Lumberjack on Wed Mar 03, 2021 11:48 am, edited 1 time in total.
Here is a simple Basic macro that finds the text between the two markers and copies it to a position just after the second marker. The original text is not deleted and the formatting is not copied. I do not see a way to copy the formatting if it has been applied manually. If you know that the formatting has been set with a character or paragraph style, that style could be applied to the text in the new position.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
trans =thiscomponent.currentcontroller.gettransferable
thiscomponent.currentcontroller.viewcursor.collapsetoend
thiscomponent.currentcontroller.inserttransferable trans
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Thanks for replied. Text is copied. Is this any way to copy formated text , for example with bold font.
Now i use insertString , mayby i should use insertTextContent.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Hi
Now i try to use getTransfarable() ( c# ) , no success. I Where is the problem? Cursor is set correct. Value of 'CurString' object is ok. But value is not copy below CurString position. Mayby selection
Sub Main
c=thiscomponent.currentcontroller
c.select thiscomponent.gettext
trans = c.gettransferable
c.viewcursor.collapsetoend
c.inserttransferable trans
End Sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
But i have the question.
Is the any way to replace text from one to another in selection only (not in all document). From '"<el:imie />"' to "<el:imie />_1" but only in selection range. How can i do it? I want to keep formated text after replace. If '"<el:imie />"' is bold , "<el:imie />_1" should by bold .
Not sure what your asking. Are you asking how to do a search operation just on the selected text? If so I think you have to either use the dispatchhelper (the macro record will produce some code in BASIC for that which you'll have to translate) or go through each result and compare the range of what's found to the selection using XTextRangeCompare
It is possible i want to search and replace text in selected range. Now i use code to replace text in all document in success. This code replace 'text1' to 'text2' but in whole document (oDoc is all document).
I want use similar code to replace but in selection.
Record a macro and translate it into your language - I'm pretty sure you have to do that and you can't do it another way. Search in selection isn't an option in the searchdescriptor API method.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)