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

Newbie with .loadComponentFromURL problem

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


Joined: 25 Mar 2009
Posts: 3

PostPosted: Wed Mar 25, 2009 2:00 pm    Post subject: Newbie with .loadComponentFromURL problem Reply with quote

I am new to Oo and am trying to write a macro in OoCalc to convert a directory of .123 files (Lotus 123) to .xls files. I am unable to get around a "BASIC runtime error. Object Variable not set." error. This error occurs when attempting to access the methods of a Component object. The debugger shows the value of the Component to be 'NULL' even after the loadComponentFromURL call. Here is the code:


REM ***** BASIC *****
Sub cvt123
dim sInDir as string
dim sOutDir as string
dim sFile as string
dim sUrl as string
dim spdf as string
dim doct as object
Dim args(0) as new com.sun.star.beans.PropertyValue
Dim mFileProperties(1) As New com.sun.star.beans.PropertyValue
dim mNoArgs() ' supplies empty arg list
' get the input and output directories for the document source and pdf output
sInDir = "file:///C:/Deep1/"
sOutDir ="file:///C:/Deep2/"
sFile = Dir(sInDir+"*.123") ' can be any valid selection for file namesnnnn

oDesktop = createUnoService("com.sun.star.frame.Desktop")
args(0).Name = "ReadOnly"
args(0).Value = True
While sFile <> ""
sURL = sIndir+sfile

'PROBLEM
doct=oDesktop.loadComponentFromURL(sURL,"_blank",0,args()) 'doct WILL NOT INSTANTIATE!!!!
'END PROBLEM

' output file name replace the .xxx with .sxw
spdf =sOutDir+ left(sfile,len(sfile)-4)+".xls"

'set properties

sURL = spdf
mFileProperties(0).Name = "Overwrite"
mFileProperties(0).Value = FALSE
mFileProperties(1).Name = "FilterName"
mFileProperties(1).Value = "MS Excel 97" 'from recording macro on OOo
' store as
doct.storeAsURL(sURL, mFileProperties())
' unload the document object
doct.dispose()
' get next filename null when none left
sfile = dir
wend
End Sub


Thanks in advance for any help.
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Sat Mar 28, 2009 5:04 am    Post subject: Reply with quote

your code works for me

ms777
Back to top
View user's profile Send private message
gnome_de_BOOM
Newbie
Newbie


Joined: 25 Mar 2009
Posts: 3

PostPosted: Sat Mar 28, 2009 5:57 am    Post subject: Hmmm Reply with quote

I get the error consistently on a Windows XP machine. What operating system are you running it on?

Thanks for the reply.
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10065
Location: Germany

PostPosted: Sat Mar 28, 2009 6:46 am    Post subject: Reply with quote

http://www.oooninja.com/2008/02/batch-command-line-file-conversion-with.html

Why does anybody convert to xls? MS published the specs of the file format which proves that it is dead horse.
ODF is the future-safe file format. http://user.services.openoffice.org/en/forum/viewtopic.php?f=74&t=16700
_________________
Rest in peace, oooforum.org
Get help on http://forum.openoffice.org
Back to top
View user's profile Send private message
gnome_de_BOOM
Newbie
Newbie


Joined: 25 Mar 2009
Posts: 3

PostPosted: Sat Mar 28, 2009 8:11 am    Post subject: Reply with quote

I'll let you ask my client that.
Back to top
View user's profile Send private message
ms777
Super User
Super User


Joined: 07 Feb 2004
Posts: 1355

PostPosted: Sat Mar 28, 2009 8:22 am    Post subject: Reply with quote

My ealier statement was nonsense: I only tried with .ods file, and then it works.

If you want me to check with .123 file please post an example somewhere

Good luck,

ms777


XP SP3 OO 2.4
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