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

Convert *.dbf to *.sxc and *.xls using Macros ?

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


Joined: 10 Feb 2004
Posts: 56
Location: Frankfurt/Main Germany

PostPosted: Tue Feb 10, 2004 4:17 am    Post subject: Convert *.dbf to *.sxc and *.xls using Macros ? Reply with quote

Hello Everybody Smile ,

*Sorry for Posting this twice, but first Posting was in wrong Forum Area* Sad

I have been searching and browsing this forum for some time now,
and wanted to thank everybody for the information given here.
It helped me a lot getting started with OpenOffice and macro writing.

Now i got a problem that I haven't found yet on the forum.

I'm using some *.dbf tables as DataSources for a form, that works fine.

Question Now i want to convert a specific result *.dbf file into a *.sxc and or *.xls file.
It works well using the menu Options, but i want to convert the file using a macro.
I tried to record the macro, but that didn't work. Question

I'm thankful for any help on this topic,

Peter Biela
_________________
Question Who is John Galt? - Ayn Rand Question
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Tue Feb 10, 2004 3:39 pm    Post subject: Reply with quote

This would seem to be a straightforward conversion problem....
Code:
Sub Main
   cDbfFileToOpen = "/home/danny/Desktop/test.dbf"
   cSxcFileToSave = "/home/danny/Desktop/test.sxc"
   cXlsFileToSave = "/home/danny/Desktop/test.xls"
   cPdfFileToSave = "/home/danny/Desktop/test.pdf"
   cHtmlFileToSave = "/home/danny/Desktop/test.html"
   
   ' First open file.
   oCalcDoc = StarDesktop.loadComponentFromURL( ConvertToURL( cDbfFileToOpen ), "_blank", 0,_
      Array( MakePropertyValue( "FilterName", "dBase" ),_
            MakePropertyValue( "FilterOptions", "" ) ) )
   
   ' Now save it as Calc.
   oCalcDoc.storeToURL( ConvertToURL( cSxcFileToSave ), Array() )

   
   ' Now save it as Excel.
   oCalcDoc.storeToURL( ConvertToURL( cXlsFileToSave ),_
      Array( MakePropertyValue( "FilterName", "MS Excel 97" ) ) )
   
   ' Now save it as PDF.
   oCalcDoc.storeToURL( ConvertToURL( cPdfFileToSave ),_
      Array( MakePropertyValue( "FilterName", "calc_pdf_Export" ) ) )
   
   ' Now save it as Html.
   oCalcDoc.storeToURL( ConvertToURL( cHtmlFileToSave ),_
      Array( MakePropertyValue( "FilterName", "HTML (StarCalc)" ) ) )
   
   ' Now close document.
   oCalcDoc.close( True )
End Sub

Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
   Dim oPropertyValue As New com.sun.star.beans.PropertyValue
   If Not IsMissing( cName ) Then
      oPropertyValue.Name = cName
   EndIf
   If Not IsMissing( uValue ) Then
      oPropertyValue.Value = uValue
   EndIf
   MakePropertyValue() = oPropertyValue
End Function



Other posts where questions about document format conversion issues are answered....

List of many past conversion examples
http://www.oooforum.org/forum/viewtopic.php?t=4998

Filter list
http://www.oooforum.org/forum/viewtopic.php?t=3549

Xcel to Calc conversion using the API
http://www.oooforum.org/forum/viewtopic.php?t=2668
A very similar one, converting Xcel to Text
http://www.oooforum.org/forum/viewtopic.php?t=2819

Batch mode conversion
http://www.oooforum.org/forum/viewtopic.php?p=16056#16056

Document conversion
http://www.oooforum.org/forum/viewtopic.php?t=4163

VB: converting Excel files to txt files
http://www.oooforum.org/forum/viewtopic.php?t=3194

Converting Word -> PDF from the command line
http://www.oooforum.org/forum/viewtopic.php?t=3772
http://www.oooforum.org/forum/viewtopic.php?t=5513
Convert Excel -> PDF from the command line
http://www.oooforum.org/forum/viewtopic.php?t=5596
see tail end of thread...
http://www.oooforum.org/forum/viewtopic.php?t=3772

Converting SXW -> PDF
http://www.oooforum.org/forum/viewtopic.php?t=3017

In Python...
http://www.oooforum.org/forum/viewtopic.php?t=3451

Thread about converting document to PDF in Java
http://www.oooforum.org/forum/viewtopic.php?t=1480

I wrote a batch document converter
http://www.oooforum.org/forum/viewtopic.php?t=3525
http://www.oooforum.org/forum/viewtopic.php?t=2810
http://www.oooforum.org/forum/viewtopic.php?p=10311#10311
you can get it here
http://www.ooomacros.org/files.php?type=macro#DocumentConverter
more discussion of it here...
http://www.oooforum.org/forum/viewtopic.php?t=5708

Macro to save in three formats
http://www.oooforum.org/forum/viewtopic.php?t=3612

http://www.oooforum.org/forum/viewtopic.php?t=5308
http://www.oooforum.org/forum/viewtopic.php?t=3973
http://www.oooforum.org/forum/viewtopic.php?t=3768
http://www.oooforum.org/forum/viewtopic.php?t=3620
http://www.oooforum.org/forum/viewtopic.php?t=3545
http://www.oooforum.org/forum/viewtopic.php?t=3476
http://www.oooforum.org/forum/viewtopic.php?t=3017

Discussion that ends in DocConverter utility.
http://www.oooforum.org/forum/viewtopic.php?t=2668

Convert PPT to HTML from command line...
http://www.oooforum.org/forum/viewtopic.php?t=5137
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
PBiela
Power User
Power User


Joined: 10 Feb 2004
Posts: 56
Location: Frankfurt/Main Germany

PostPosted: Wed Feb 11, 2004 6:55 am    Post subject: Reply with quote

Hello DannyB,

thank you very much! That's exactly what I've been looking for! Laughing

Thank you too for the links, I'll browse through them!

Peter Biela
_________________
Question Who is John Galt? - Ayn Rand Question
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Wed Feb 25, 2004 8:39 am    Post subject: Reply with quote

An excellent followup to this thread is continued here....
http://www.oooforum.org/forum/viewtopic.php?t=6058
_________________
Want to make OOo Drawings like the colored flower design to the left?
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