[Solved] Controlling OOo from Classic ASP

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
Combat Medic
Posts: 1
Joined: Tue Sep 09, 2008 4:55 pm

[Solved] Controlling OOo from Classic ASP

Post by Combat Medic »

I'm trying to use OOo to do some file conversions for me. When I use VBScript everything works perfectly, however when I use the same code in ASP it runs forever. Can anyone tell me what I'm doing wrong? I tried changing the option for running hidden to false and that didn't help.

Thank you,
Mike

Classic - ASP

Code: Select all

<%
response.buffer=false
path = Server.MapPath(".")
token = "0fb3c04ce5baa5e331d55b378a787ad4"

Function MakePropertyValue(cName, uValue)
Dim oStruct
Set oStruct = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oStruct.Name = cName
oStruct.Value = uValue
Set MakePropertyValue = oStruct
End Function 

strfname= path & "\output\" & token & ".rtf"
'msgbox(StrFname)
'change the path to openoffice url format
StrFname = Replace(StrFname, ":" , "|")
StrFname = Replace(StrFname, "\" , "/")
StrFname = "file:///" & StrFname

' main
Dim objServiceManager
Dim objDesktop
Dim args(0)
Dim cURL
Dim oDoc

Set objServiceManager= CreateObject("com.sun.star.ServiceManager")
Set Stardesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")

cURL = StrFname

Set args(0) = MakePropertyValue("Hidden", False)
'Set args(0) = MakePropertyValue("Hidden", True)
Set oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, args )

'cURL = Left(StrFname, len(StrFname)-4) & ".doc"
'Set args(0) = MakePropertyValue( "FilterName", "MS Word 97" )

cURL = Left(StrFname, len(StrFname)-4) & ".pdf"
Set args(0) = MakePropertyValue( "FilterName", "writer_pdf_Export" )

call oDoc.storeToURL( cURL, args )
oDoc.close( True )

Set oDoc = nothing
Set Stardesktop = nothing
Set objServiceManager = nothing


%>

VBScript

Code: Select all

Function MakePropertyValue(cName, uValue)
Dim oStruct
Set oStruct = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oStruct.Name = cName
oStruct.Value = uValue
Set MakePropertyValue = oStruct
End Function 

'get argument passed on to this VBscript
Dim StrFname
strfname="c:\temp\0fb3c04ce5baa5e331d55b378a787ad4.rtf"
'msgbox(StrFname)
'change the path to openoffice url format
StrFname = Replace(StrFname, ":" , "|")
StrFname = Replace(StrFname, "\" , "/")
StrFname = "file:///" & StrFname

' main
Dim objServiceManager
Dim objDesktop
Dim args(0)
Dim cURL
Dim oDoc

Set objServiceManager= CreateObject("com.sun.star.ServiceManager")
Set Stardesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")

cURL = StrFname

Set args(0) = MakePropertyValue("Hidden", True)
Set oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, args )

'cURL = Left(StrFname, len(StrFname)-4) & ".doc"
'Set args(0) = MakePropertyValue( "FilterName", "MS Word 97" )

cURL = Left(StrFname, len(StrFname)-4) & ".pdf"
Set args(0) = MakePropertyValue( "FilterName", "writer_pdf_Export" )

call oDoc.storeToURL( cURL, args )
oDoc.close( True )

Set oDoc = nothing
Set Stardesktop = nothing
Set objServiceManager = nothing
Last edited by Combat Medic on Tue Sep 09, 2008 10:12 pm, edited 1 time in total.
OOo 2.4.X on Ms Windows XP
User avatar
Villeroy
Volunteer
Posts: 31363
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Controlling OOo from Classic ASP

Post by Villeroy »

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply