Calc error on re-saving

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Calc error on re-saving

Post by Peterd51 »

Hi,

I've converted one of my VB programs to use Calc in place of Excel, everything works as expected, but I'm getting an error on re-saving the doc.

Run-time error '1001':
Com.sun.star.task.ErrorCodeIOException:

Code: Select all

'Create and save Calc, working OK
  URL = "file:///" & FileNme
  Call ConvertURL		                                       'set '/' and '%20' in spaces
  Call oDoc.storeToURL(URL, arg())                            'save OK


'Later, reload doc, working OK
  URL = "file:///" & FileNme
    
  Call ConvertURL		                                        'set '/' and '%20' in spaces
  
  Set oDoc = oDesk.loadComponentFromURL(URL, "_blank", 0, arg())
  
  Set oSheets = oDoc.getSheets()                               'find all OOo sheets
  Set oSheet = oSheets.getByName("Sheet1")              'select sheet in OOo
    
  Set oSheet = oDoc.CurrentController.ActiveSheet       'set sheet in VB

'add some more data into cells, all OK, then

  Call oDoc.storeToURL(URL, arg())                              're-save gives the error


'I've also tried adding these, both give me the error:
  Set arg(0) = oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
 
  arg(0).Name = "hidden"
  arg(0).Value = ""

'or:
  arg(0).Name = "Overwrite"
  arg(0).Value = True

Do I need to 'close' it, or do something else to the file, before resaving?

Regards
Peter
OpenOffice 4.1.4 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Calc error on re-saving

Post by Zizi64 »

What fileformat are you using for the resaving the file?

Can you upload your sample file here?
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Calc error on re-saving

Post by Peterd51 »

Hi,

it's the standard .ods file. The first save is OK but the same code in the same sub fails the 2nd time.

The file contains data that I can't re-publish and if I hack around with it to 'clean it up' then you'll not be seeing it exactly as I try to re-save it.

Regards
Peter
OpenOffice 4.1.4 on Windows 10
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Calc error on re-saving

Post by UnklDonald418 »

According to Open Office Help → Open Office Basic → Error Function [Runtime] → Error Codes
1001 Object does not have this method
Perhaps you need to use the MRI Tool to see what methods are available in that situation
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Calc error on re-saving

Post by Peterd51 »

Hi,

sorry about this...

poking around I found that 'StoreToURL' gives me the error while 'StoreAsURL' seems to work OK.

Is there any specific reasons for using one or the other command...

other than 'StoreTo' doesn't seem to like re-saving a file that's just been opened?

Oh, also 'StoreAS' changes the name at the top of the spreadsheet while 'StoreTo' leaves it as 'Untitled 1'.

Regards
Peter
OpenOffice 4.1.4 on Windows 10
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Calc error on re-saving

Post by Peterd51 »

UnklDonald418,

thanks for your suggestion, I found something with poke'n'hope.

Regards
Peter
OpenOffice 4.1.4 on Windows 10
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Calc error on re-saving

Post by UnklDonald418 »

If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
UnklDonald418
Volunteer
Posts: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Calc error on re-saving

Post by UnklDonald418 »

If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Calc error on re-saving

Post by Peterd51 »

Hi UnklDonald418

Thanks for the links.

I'm not sure about:
'storeAsURL() will throw an exception if a pure export filter is used, it will accept only combined import/export filters'

as this command works OK with no 'arg' set, or with 'hidden', etc, but this description seems to be telling me that it shouldn't.

Regards
Peter
OpenOffice 4.1.4 on Windows 10
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Calc error on re-saving

Post by RoryOF »

Have you seen this
https://wiki.openoffice.org/wiki/Saving_a_document

As I understand it, StoreTo assumes an existing document, StoreAs generates a new one. Any difference in behaviour is probably due to the assumed default parameters.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Calc error on re-saving

Post by Villeroy »

Open a new text document.

ThisComponent.store() fails because the document has no pathname yet.
ThisComponent.storeToURL("file:///tmp/test.odt", Array()) stores another copy to the specified pathname without saving the current document. The current document title remains "Untitled 1". File>Properties... shows no pathname.
ThisComponent.storeAsURL("file:///tmp/test.odt", Array()) actually stores the current component to the specified pathname.

Do some dummy editing.
ThisComponent.storeToURL("file:///tmp/test_2.odt", Array()) stores another copy to the specified pathname without saving the current document. The current document title remains "test.odt". File>Properties... shows the old pathname and the current document is not saved.
Now ThisComponent.store() saves /tmp/test.odt.
ThisComponent.storeAsURL("file:///tmp/test_3.odt", Array()) stores the current component to the specified pathname. Now you are editing test_3.odt
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Calc error on re-saving

Post by Zizi64 »

As I understand it, StoreTo assumes an existing document, StoreAs generates a new one.
And there is a more difference related to the active document after the Storing procedure.

The "StoreAs..." will save the active document with a new URL (and/or to a new output format), and the saved one will be the editable (active) document, the original one will be "closed" automatically.

The "StoreTo..." will export the active document with a new URL (and/or to a new output format), but the original one will be/stay the editable active document.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Peterd51
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Calc error on re-saving

Post by Peterd51 »

Hi,

thanks for the suggestions, I'll play around with it a bit more.

Regards
Peter
OpenOffice 4.1.4 on Windows 10
Post Reply