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

document.Close() crashes other open windows, causes recovery

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


Joined: 24 Dec 2010
Posts: 8

PostPosted: Wed Dec 29, 2010 7:59 am    Post subject: document.Close() crashes other open windows, causes recovery Reply with quote

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
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Wed Dec 29, 2010 9:31 am    Post subject: Reply with quote

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:
Code:
   arr = new Array(2)

_________________
Bernard

OpenOffice.org 1.1.5 fr / Apache OpenOffice 4.0.1 / LibreOffice 4.1.0
MS-Windows 7 Home SP1
This forum is spammed, use instead Apache OpenOffice forums
Back to top
View user's profile Send private message Visit poster's website
DanCooperstock
General User
General User


Joined: 24 Dec 2010
Posts: 8

PostPosted: Wed Dec 29, 2010 9:53 am    Post subject: Reply with quote

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:
Code:
   arr = new Array(2)


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
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