OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

UNO Automation: Can one load a doc without opening a window?

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
nathandelane
Newbie
Newbie


Joined: 20 Aug 2007
Posts: 2

PostPosted: Mon Aug 20, 2007 5:08 am    Post subject: UNO Automation: Can one load a doc without opening a window? Reply with quote

I have been playing around with UNO to automate getting data from a spreadsheet, and have been successful. I have been using Ruby to accomplish this in Windows with the win32ole gem, and I am to the point where I am wondering if OpenOffice.org has a feature, where using UNO I can either hide the window or cause it not to open when I load a document. If there is a way, then I'd appreciate learning about how to do it. I've looked through all of the documentation that I could find so far, and I haven't been able to answer my question that way. Also as it goes, most of the documentation seems to be incomplete on automation using UNO.

So here is the basic script I created to open a document as an example, using Ruby:

Code:
require "win32ole"

noArgs = []

serviceManager = WIN32OLE.new("com.sun.star.ServiceManager")
desktop = serviceManager.createInstance("com.sun.star.frame.Desktop")
spreadsheet = desktop.loadComponentFromURL(
  "file:///c:/test.ods",
  "_blank",
  0,
  noArgs)


So is there some argument I could place in the noArgs array to satisfy my need? Any information would be great.

Thanks,

Nathan


Last edited by nathandelane on Mon Aug 20, 2007 7:03 am; edited 2 times in total
Back to top
View user's profile Send private message
vbms
Power User
Power User


Joined: 13 Aug 2007
Posts: 63

PostPosted: Mon Aug 20, 2007 6:02 am    Post subject: Reply with quote

yes this works ... your noargs array must contain the property with name "Hidden" and value ummm true in java this peice of code looks like this ...

Code:

            com.sun.star.beans.PropertyValue[] propertyValue =
                new com.sun.star.beans.PropertyValue[1];
            propertyValue[0] = new com.sun.star.beans.PropertyValue();
            propertyValue[0].Name = "Hidden";
            propertyValue[0].Value = new Boolean(true);
           
            // load the document
            documentComponent = xCompLoader.loadComponentFromURL(
                sLoadUrl.toString(), "_blank", 0, propertyValue );


np
Back to top
View user's profile Send private message
nathandelane
Newbie
Newbie


Joined: 20 Aug 2007
Posts: 2

PostPosted: Mon Aug 20, 2007 6:56 am    Post subject: Reply with quote

Thank you very much. That totally worked. So here's what I did in Ruby:

Code:
require "win32ole"

noArgs = []

serviceManager = WIN32OLE.new("com.sun.star.ServiceManager")
hidden = serviceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
hidden.Name = "Hidden"
hidden.Value = true
noArgs << hidden
desktop = serviceManager.createInstance("com.sun.star.frame.Desktop")
spreadsheet = desktop.loadComponentFromURL(
  "private:factory/scalc",
  "_blank",
  0,
  noArgs)


AND now my document is loaded, but the application is hidden Smile

Nathan


Last edited by nathandelane on Mon Aug 20, 2007 7:16 am; edited 1 time in total
Back to top
View user's profile Send private message
vbms
Power User
Power User


Joined: 13 Aug 2007
Posts: 63

PostPosted: Mon Aug 20, 2007 7:13 am    Post subject: Reply with quote

np man, we help each other
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group