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

Create a new document without opening a new window?

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


Joined: 18 Jul 2008
Posts: 11

PostPosted: Wed Sep 03, 2008 2:38 pm    Post subject: Create a new document without opening a new window? Reply with quote

Hi, I'm trying to write a macro that creates and saves a new Calc document, but with the only command I can find so far,

Code:
Dim Dummy()
Dim Url As String
Dim Doc As Object

Url = "private:factory/scalc"
Doc = StarDesktop.loadComponentFromURL(Url, "_blank", 0, Dummy())


that is, loadComponentFromURL(), always opens a new window with the blank document. I need to be able to create the document, set it up (using the macro), and then save it to my computer without having the new window opened. The reason is because I need to create a ton of new documents, and having 50 new windows opening up would be just ridiculous.

Any thoughts?
Back to top
View user's profile Send private message
turtle47
Power User
Power User


Joined: 24 Aug 2008
Posts: 66
Location: Germany

PostPosted: Wed Sep 03, 2008 3:34 pm    Post subject: Reply with quote

Hi,

Quote:
Any thoughts?


Code:
Sub Create_Calc_File
   Dim oDocument as object
   dim myFileProp(0) as New com.sun.star.beans.PropertyValue
   myFileProp(0).name="Hidden"
   myFileProp(0).value=True
   oDocument = StarDesktop.loadComponentFromURL ("private:factory/scalc","_blank", 0, myFileProp())
   dim dummy()
   oDocument.storeToURL(("File:///D:/Testfolder/Testfile.ods") , dummy())
End Sub

JD
Back to top
View user's profile Send private message
jason102
General User
General User


Joined: 18 Jul 2008
Posts: 11

PostPosted: Wed Sep 03, 2008 3:49 pm    Post subject: Reply with quote

OK, yeah I read about the storeToURL() method, but when I run the macro thru Calc I get an error:

"Basic runtime error.
An exception occurred.
Type: com.sun.star.task.ErrorCodeIOException
Message: ."

All I did was alter the filepath for saving the file to my hard drive:

Code:
Sub Create_Calc_File
   Dim oDocument as object
   dim myFileProp(0) as New com.sun.star.beans.PropertyValue
   myFileProp(0).name="Hidden"
   myFileProp(0).value=True
   oDocument = StarDesktop.loadComponentFromURL ("private:factory/scalc","_blank", 0, myFileProp())
   dim dummy()
   oDocument.storeToURL(("File:///C:/test.ods") , dummy())
End Sub
Back to top
View user's profile Send private message
jason102
General User
General User


Joined: 18 Jul 2008
Posts: 11

PostPosted: Sat Sep 13, 2008 9:37 pm    Post subject: Reply with quote

bump - Anyone know why I could be getting this mysterious runtime error?
Back to top
View user's profile Send private message
turtle47
Power User
Power User


Joined: 24 Aug 2008
Posts: 66
Location: Germany

PostPosted: Sat Sep 13, 2008 9:56 pm    Post subject: Reply with quote

What´s your OS? Vista?
In what line comes the error message?

If the error in this line:
Code:
oDocument.storeToURL(("File:///C:/test.ods") , dummy())


"C:/" doesent exist or check the read and write options of your folder!
Back to top
View user's profile Send private message
jason102
General User
General User


Joined: 18 Jul 2008
Posts: 11

PostPosted: Sat Sep 13, 2008 10:20 pm    Post subject: Reply with quote

OK, I'm not sure what the problem was with my Windows XP computer at work, but my Linux system here at home was able to execute the command flawlessly:
Code:
oDocument.storeToURL(("File:///home/jason/test.ods") , dummy())

Maybe I had too many '/' characters after File: or I should have possibly used '\' instead? I'm not sure, but I really need this to work on my home computer, which it does, so while I'm not sure why it wouldn't work on XP my problem is solved! Thank you!
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