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 question - OOo as internet service...

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


Joined: 03 Mar 2006
Posts: 2

PostPosted: Fri Mar 03, 2006 2:09 am    Post subject: newbie question - OOo as internet service... Reply with quote

Hi,
I administer our faculty intranet (http://wwwedu.oulu.fi/intra/), which is build on iHTML (www.ihtml.com - a server extension little like PHP or ColdFusion).
We used to have a handy function: Word documents uploaded to server could be automaticly converted to HTML. Now we upgraded to new server (Win2003, IIS 6) and that function does not work any more, becaus of the complicated user and security systems of Win2003, IIS6 an Office. There is an article "Considerations for server-side Automation of Office" at http://support.microsoft.com/default.aspx?scid=kb;en-us;257757 which says with bold:
Quote:
"Microsoft does not currently recommend, and does not support, Automation
of Microsoft Office applications from any unattended, non-interactive
client application or component (including ASP, DCOM, and NT Services),
because Office may exhibit unstable behavior and/or deadlock when run in
this environmen
t."

So I am turning to Open Office. Do you think this scenario is possible to make easily(?!) with OOo. I tell how it was done in our old server:
1. A word document, say D:\files\document.doc is already server
2. iHTML runs MSWord with a commadline:
"C:\Program Files\Microsoft Office\Office11\WINWORD.EXE" D:\files\document.doc /mSaveHTML
3. Word starts, opens document.doc and runs a macro SaveHTML
4. This macro saves the document as HTML, closes the document and quits Word

Now in our new server Word just starts, but it has no access to any macros!

Thank you very much!

Eetu Pikkarainen
Back to top
View user's profile Send private message
gpl_racer
Power User
Power User


Joined: 08 Sep 2005
Posts: 83
Location: Finland

PostPosted: Fri Mar 03, 2006 4:38 am    Post subject: Reply with quote

Here is the code to save the document as HTML:
Code:

Sub ConvertDocumentToHTML
Globalscope.BasicLibraries.loadLibrary("Tools")
oDocument = ThisComponent
filePath = oDocument.getURL()   'read the URL where original file if
fileName = GetFileNameWithoutExtension(filePath)   'delete the extension
fileName = FileNameoutofPath(fileName)      'extract the file name
dirName = DirectoryNameoutofPath(filePath, "/")      'extract the directory where the file is
dirName = ConvertFromURL(dirName)   'convert the directory from URL to normal path
dirName = ReplaceString(dirName, "/", "\")   'replace all "\" with "/" for the storeToURL
oDocument.storeToURL("file:///" + dirName + "/" + fileName + ".html", Array(MakePropertyValue("FilterName", "HTML (StarWriter)")))   'save the file as HTML
oDocument.close(false)   'close the document
End Sub


For that code to work youll also need this small macro by DannyB:
Code:

Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
   oPropertyValue = createUnoStruct( "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


The macros need to be saved to "Standard" library and "Module1" module (otherwise change the commandline command below accordingly)...

The commandline command to execute the conversion macro:
"C:\Program Files\OpenOffice.org 2.0\program\soffice.exe "G:\test.doc" "macro:///Standard.Module1.ConvertDocumentToHTML"

P.S. Im from Finland too but I wrote in English instead of Finnish so that anyone else reading this can understand...
Back to top
View user's profile Send private message
eetu
Newbie
Newbie


Joined: 03 Mar 2006
Posts: 2

PostPosted: Fri Mar 03, 2006 5:11 am    Post subject: Reply with quote

Thank you, Kiitoksia!!!

Sounds promising. May be that I can start testing this only after the skiing holidays Smile

btw. is PDF conversion about similar?

eetu
Back to top
View user's profile Send private message
gpl_racer
Power User
Power User


Joined: 08 Sep 2005
Posts: 83
Location: Finland

PostPosted: Fri Mar 03, 2006 5:31 am    Post subject: Reply with quote

eetu wrote:

btw. is PDF conversion about similar?
eetu


Its exactly the same...

Code:

Sub ConvertDocumentToPDF
Globalscope.BasicLibraries.loadLibrary("Tools")
oDocument = ThisComponent
filePath = oDocument.getURL()   'read the URL where original file if
fileName = GetFileNameWithoutExtension(filePath)   'delete the extension
fileName = FileNameoutofPath(fileName)      'extract the file name
dirName = DirectoryNameoutofPath(filePath, "/")      'extract the directory where the file is
dirName = ConvertFromURL(dirName)   'convert the directory from URL to normal path
dirName = ReplaceString(dirName, "/", "\")   'replace all "\" with "/" for the storeToURL
oDocument.storeToURL("file:///" + dirName + "/" + fileName + ".pdf", Array(MakePropertyValue("FilterName", "writer_pdf_Export")))   'save the file as HTML
oDocument.close(false)   'close the document
End Sub


As you can see only the parameter of the storeToURL changed and now it exports to PDF... If you need to make more conversions, look at the complete list of Filter names by DannyB...
Back to top
View user's profile Send private message
jjgiopa
Newbie
Newbie


Joined: 08 Mar 2006
Posts: 4
Location: Pisa, Italy

PostPosted: Wed Mar 22, 2006 1:50 am    Post subject: Reply with quote

Hy !
I'm writing a ASP.NET appliction using OO to convert odt into pdf. I've use the gpl_racer's macro code called via shell and works fine on winXP-iis5, but I've a problem with win2003-ii6.

my question is : is possible invoke a macro via cli_uno ? or have you some advice to configure iis6 to execute correctly oo via shell ?

thanks all.
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