| View previous topic :: View next topic |
| Author |
Message |
jason102 General User

Joined: 18 Jul 2008 Posts: 11
|
Posted: Wed Sep 03, 2008 2:38 pm Post subject: Create a new document without opening a new window? |
|
|
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 |
|
 |
turtle47 Power User

Joined: 24 Aug 2008 Posts: 66 Location: Germany
|
Posted: Wed Sep 03, 2008 3:34 pm Post subject: |
|
|
Hi,
| 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 |
|
 |
jason102 General User

Joined: 18 Jul 2008 Posts: 11
|
Posted: Wed Sep 03, 2008 3:49 pm Post subject: |
|
|
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 |
|
 |
jason102 General User

Joined: 18 Jul 2008 Posts: 11
|
Posted: Sat Sep 13, 2008 9:37 pm Post subject: |
|
|
| bump - Anyone know why I could be getting this mysterious runtime error? |
|
| Back to top |
|
 |
turtle47 Power User

Joined: 24 Aug 2008 Posts: 66 Location: Germany
|
Posted: Sat Sep 13, 2008 9:56 pm Post subject: |
|
|
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 |
|
 |
jason102 General User

Joined: 18 Jul 2008 Posts: 11
|
Posted: Sat Sep 13, 2008 10:20 pm Post subject: |
|
|
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 |
|
 |
|