[Solved] Save XLS as Microsoft Excel 5.0

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
giovannigiorgio
Posts: 3
Joined: Mon Mar 06, 2023 6:45 pm

[Solved] Save XLS as Microsoft Excel 5.0

Post by giovannigiorgio »

Hello everybody,
some xls files on my pc are not read with vb.net. But if I save xls file as Microsoft Excel 5.0 the problem disappears.
But I am having this problem: I need saving file as Microsoft Excel 5.0 have to be programmatically executed!
Can anyone help me to solve this problem?
Thanks in advance.
Last edited by MrProgrammer on Fri Mar 10, 2023 4:19 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
OpenOffice 3.1 on Windows Vista
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Save xls as Microsoft Excel 5.0

Post by Zizi64 »

I need saving file as Microsoft Excel 5.0 have to be programmatically executed!
Can anyone help me to solve this problem?
Import-export filter list:
https://wiki.openoffice.org/wiki/Framew ... st_OOo_3_0
https://help.libreoffice.org/latest/en- ... lters.html

Sample code:
viewtopic.php?t=104383

I suggest you to start with Andrew Pitonyak's free macro books.

Excel 5.0 is an archaic old file format. You will lose many formatting properties and maybe some contents when you export your document into that file format.
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.
giovannigiorgio
Posts: 3
Joined: Mon Mar 06, 2023 6:45 pm

Re: Save xls as Microsoft Excel 5.0

Post by giovannigiorgio »

Hello Zizi64,
thank you for assistance. My problem is not solved but I tested succesfully some code form open and close xls file.
Here is my code with vb.net:

Code: Select all

Dim oDoc As Object

                    Dim oSM As Object
                    Dim oDesk As Object

                    Dim path = "private:factory/scalc"
                    Dim Url = "file:///C:/Users/giorg/Documents/Importanti/fsi-2018.xls"
                    oSM = CreateObject("com.sun.star.ServiceManager")
                    oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
                    Dim noArgs(-1)
                    oDoc = oDesk.loadComponentFromURL(Url, "_blank", 0, noArgs)

                    oDoc.dispose
                    oDoc = Nothing
                    oDesk = Nothing
                    oSM = Nothing
but I want to save a xls file programmatically.
Any idea?
OpenOffice 3.1 on Windows Vista
giovannigiorgio
Posts: 3
Joined: Mon Mar 06, 2023 6:45 pm

Re: Save xls as Microsoft Excel 5.0

Post by giovannigiorgio »

Hello Zizi64.
Problem solved. Here is my vb.net code:

Code: Select all

Try
                'Root object for accessing OpenOffice from VB
                Dim arg()

                'Ignore it for the moment !
                Dim Url = "file:///C:/Users/giorg/Documents/Importanti/fsi-2018.xls"
                'Instanciate OOo : this line is mandatory with VB for OOo API
                Dim oSM = CreateObject("com.sun.star.ServiceManager")
                'Create the first and most important service
                Dim oDesk = oSM.createInstance("com.sun.star.frame.Desktop")

                'Create a new doc
                Dim noArgs(-1)
                Dim oDoc = oDesk.loadComponentFromURL(Url, "_blank", 0, noArgs)
                'Close the doc



                'Open an existing doc (pay attention to the syntax for first argument)

                'Save the doc
                oDoc.storeToURL("file:///C:/Users/giorg/Documents/Importanti/fsi-20181.xls", noArgs)
                'Close the doc
                For Each process As Process In Process.GetProcessesByName("soffice.bin")
                    process.Kill()
                    process.WaitForExit()
                Next
                My.Computer.FileSystem.DeleteFile("C:\Users\giorg\Documents\Importanti\fsi-2018.xls")
                My.Computer.FileSystem.RenameFile("C:\Users\giorg\Documents\Importanti\fsi-20181.xls", "fsi-2018.xls")

            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
Another thing, please:
I want publish on sourceforgenet my application. Do you know if I I in setup file have to insert all Openoffice setup , or only some dlls maybe got from Openoffice sdk?
Thanks in advance!
OpenOffice 3.1 on Windows Vista
Post Reply