| View previous topic :: View next topic |
| Author |
Message |
gnome_de_BOOM Newbie

Joined: 25 Mar 2009 Posts: 3
|
Posted: Wed Mar 25, 2009 2:00 pm Post subject: Newbie with .loadComponentFromURL problem |
|
|
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 |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Sat Mar 28, 2009 5:04 am Post subject: |
|
|
your code works for me
ms777 |
|
| Back to top |
|
 |
gnome_de_BOOM Newbie

Joined: 25 Mar 2009 Posts: 3
|
Posted: Sat Mar 28, 2009 5:57 am Post subject: Hmmm |
|
|
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 |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
|
| Back to top |
|
 |
gnome_de_BOOM Newbie

Joined: 25 Mar 2009 Posts: 3
|
Posted: Sat Mar 28, 2009 8:11 am Post subject: |
|
|
| I'll let you ask my client that. |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Sat Mar 28, 2009 8:22 am Post subject: |
|
|
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 |
|
 |
|