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

Joined: 24 Dec 2010 Posts: 8
|
Posted: Wed Dec 29, 2010 7:59 am Post subject: document.Close() crashes other open windows, causes recovery |
|
|
OK, I'm narrowing down my problem from previous threads that haven't really been solved. I'm trying to use JavaScript to open an Excel doc and save it as text. T
he problem is, when sheet.Close(true) is called, if there are other previously open OO windows (say a Writer window), they also close, and then they do a recovery. Seems like a bug, but I don't know what to do about it. If I omit sheet.Close(), there is no problem with other open windows, and of course the sheet that was opened by the script doesn't close either.
Here's the code I'm using:
| Code: | var oo = new ActiveXObject("com.sun.star.ServiceManager")
var desktop = oo.createInstance("com.sun.star.frame.Desktop")
var arr = new Array()
var sheet = desktop.loadComponentFromURL(
"file:///C:/donation/donationExcel.xls", "_blank", 0, arr)
if (sheet == null)
WScript.echo("sheet is null")
else
{
arr = new Array()
arr[0] = oo.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
arr[0].Name = "FilterName"
arr[0].Value = "Text - txt - csv (StarCalc)"
arr[1] = oo.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
arr[1].Name = "FilterOptions"
arr[1].Value = "9,34,76,1"
if (sheet.storeAsURL("file:///c:/donation/donationExcel.txt", arr) == 0)
WScript.echo("not saved as text")
sheet.Close(true)
sheet = null
}
desktop = null
oo = null
|
BTW, in case anyone was wondering, omitting setting the sheet, desktop and oo to null at the end doesn't help - it's very clearly the sheet.Close(true) that causes the crashing of other open windows. I've also tried sheet.Close(false) - no difference.
Any bright ideas? Thanks. |
|
| Back to top |
|
 |
B Marcelly Super User

Joined: 12 May 2004 Posts: 1414 Location: France
|
Posted: Wed Dec 29, 2010 9:31 am Post subject: |
|
|
Obviously you ignored my advice in the other thread:
| B Marcelly wrote: | I think your declaration of array for the storeAsURL forgets the number of elements. It should be:
|
_________________ Bernard
OpenOffice.org 1.1.5 fr / OpenOffice.org 3.4.1 en-US + langpacks, MS-Windows XP Home SP3
This forum is unusable, use instead Apache OpenOffice forums |
|
| Back to top |
|
 |
DanCooperstock General User

Joined: 24 Dec 2010 Posts: 8
|
Posted: Wed Dec 29, 2010 9:53 am Post subject: |
|
|
| B Marcelly wrote: | Obviously you ignored my advice in the other thread:
| B Marcelly wrote: | I think your declaration of array for the storeAsURL forgets the number of elements. It should be:
|
|
I'm sorry, I did see that, but arrays in JavaScript are auto-sizing if you omit an arg in the constructor, so that is unecessary and will not help anything. To make you happy, I just tested it your way, and my code is still causing the same problem.
Just to be clear, the problem is sometimes intermittent, but usually happens every time. |
|
| Back to top |
|
 |
|
|
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
|