Calc error on re-saving

Creating a macro - Writing a Script - Using the API

Calc error on re-saving

Postby Peterd51 » Sun Feb 04, 2018 3:20 pm

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   Expand viewCollapse view
'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
Peterd51
 
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Calc error on re-saving

Postby Zizi64 » Sun Feb 04, 2018 3:35 pm

What fileformat are you using for the resaving the file?

Can you upload your sample file here?
Tibor Kovacs, Hungary; LO4.4.7, LO6.1.5 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.2; AOO4.1.5
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.
User avatar
Zizi64
Volunteer
 
Posts: 7902
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Calc error on re-saving

Postby Peterd51 » Sun Feb 04, 2018 4:57 pm

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
Peterd51
 
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Calc error on re-saving

Postby UnklDonald418 » Sun Feb 04, 2018 6:45 pm

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.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1121
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Calc error on re-saving

Postby Peterd51 » Sun Feb 04, 2018 6:47 pm

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

Postby Peterd51 » Sun Feb 04, 2018 6:49 pm

UnklDonald418,

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

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

Postby UnklDonald418 » Sun Feb 04, 2018 6:54 pm

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.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1121
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Calc error on re-saving

Postby UnklDonald418 » Mon Feb 05, 2018 1:08 am

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.6 & LibreOffice 6.1.5.2 - Windows 10 Professional
UnklDonald418
Volunteer
 
Posts: 1121
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Calc error on re-saving

Postby Peterd51 » Mon Feb 05, 2018 11:21 am

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
Peterd51
 
Posts: 31
Joined: Sun Dec 31, 2017 12:06 pm

Re: Calc error on re-saving

Postby RoryOF » Mon Feb 05, 2018 11:39 am

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.6 on Xubuntu 18.04.2 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 28738
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Calc error on re-saving

Postby Villeroy » Mon Feb 05, 2018 12:20 pm

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, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26623
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Calc error on re-saving

Postby Zizi64 » Mon Feb 05, 2018 12:29 pm

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; LO4.4.7, LO6.1.5 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.2; AOO4.1.5
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.
User avatar
Zizi64
Volunteer
 
Posts: 7902
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Calc error on re-saving

Postby Peterd51 » Mon Feb 05, 2018 5:55 pm

Hi,

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

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


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 7 guests