Load currently opened OO files [C#]

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
nrkogo
Posts: 1
Joined: Mon Dec 03, 2012 12:50 am

Load currently opened OO files [C#]

Post 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.
OpenOffice 3.1 on Windows 7
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Load currently opened OO files [C#]

Post 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

Apache OpenOffice 4.1.1
Windows XP
Post Reply