Modify unsaved writer file using .Net C#

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
rajpura.mayank
Posts: 1
Joined: Fri May 27, 2022 9:25 am

Modify unsaved writer file using .Net C#

Post by rajpura.mayank »

HI Team,

I want to automate the Open office Writer and add text in opened file in Writer.
I got few sample in that either we are creating all new instance using "private:factory/swriter", or we can load already saved file using file path and add text in it.

But I don't want to save a file(until user wants), and modify the content of Writer file whichever file open in writer, or wherever the cursor is in writer?

Please let me know in case any other details you want?

Thanks,
Mayank Rajpura.
Window 10, Open office 4.1.11
JeJe
Volunteer
Posts: 2785
Joined: Wed Mar 09, 2016 2:40 pm

Re: Modify unsaved writer file using .Net C#

Post by JeJe »

The return value of loadComponentFromURL is a reference to the document which you can then use

In Basic as I don't know .Net C#:

Code: Select all


oDoc=StarDesktop.loadComponentFromURL("private:factory/swriter","_blank",0,Array())
oDoc.gettext.string = "some text"
Edit:

Alternatively there's thiscomponent

https://wiki.openoffice.org/wiki/Curren ... e_document
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Post Reply