Page 1 of 1

Modify unsaved writer file using .Net C#

Posted: Fri May 27, 2022 9:41 am
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.

Re: Modify unsaved writer file using .Net C#

Posted: Fri May 27, 2022 11:38 am
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