Page 1 of 1

Load currently opened OO files [C#]

Posted: Mon Dec 03, 2012 1:06 am
by nrkogo
Hello! I'm working on a program that can merge currently opened OO files (let's say 3 writer docs into 1). I was wondering if there's any way to get this documents and load them into Xcomponents programmatically, so i can work with them (format, delete,etc.).

Thanks in advance.

Re: Load currently opened OO files [C#]

Posted: Mon Dec 03, 2012 4:07 am
by Charlie Young
nrkogo wrote:Hello! I'm working on a program that can merge currently opened OO files (let's say 3 writer docs into 1). I was wondering if there's any way to get this documents and load them into Xcomponents programmatically, so i can work with them (format, delete,etc.).

Thanks in advance.
I kind of hate to do this since you're working in c#, but I had something that does approximately what I guess you want in Basic - to load all opened components into an array, then loop through them until q is entered in the InputBox. You should be able to operate on the components whether or not they are in the active frame.

Code: Select all

Sub LoopThroughComponents
	dim Comp as object
	Dim Comps(0) As Object
	dim x As Object
	dim i as Integer, c As Integer 
	dim cmd as String
	
	Comp=StarDesktop.Components.CreateEnumeration
	c = 0
	do while Comp.hasMoreElements()
		x=Comp.NextElement()
		Redim Preserve Comps(c) As Object
		comps(c) = x
		c = c + 1	
	loop
	cmd = ""
	i = 0
	do while cmd <> "q" and cmd <> "Q"
		Comps(i).currentController.Frame.ContainerWindow.toFront()
		cmd = InputBox("q to quit","Enter Command")
		i = (i + 1) MOD c
	loop
		
End Sub