I'm new to OpenOffice. I spent whole day try to develop the application that can open spreadsheet and save it as PDF. it seem like I couldn't make the save file successfully.
I tried to reference the .dll for my program but I couldn't find any "cli_" except "cli_uno" in "OpenOffice 4\program\cli_uno.dll". So I have to use cli_ure.dll, cli_uretypes.dll, cli_oootypes.dll, cli_cppuhelper.dll, cli_basetypes.dll from 3.0.0.0 version
Below his my code
Code: Select all
Imports unoidl.com.sun.star.lang
Imports unoidl.com.sun.star.uno
Imports unoidl.com.sun.star.bridge
Imports uno.util
Imports System
Imports System.Collections
Dim FileName As String = "C:/ExcelSheet.xls"
Sub Main()
AOOXL(FileName)
End Sub
Private Sub AOOXL(ByVal XLFileLoc As String)
Dim PDFFileName As String = "C:/SSDemo.pdf"
Try
Dim xContext As XComponentContext = Bootstrap.bootstrap()
Dim xFactory As XMultiServiceFactory = DirectCast(xContext.getServiceManager(), XMultiServiceFactory)
Dim xDesktop As unoidl.com.sun.star.frame.XDesktop = DirectCast(xFactory.createInstance("com.sun.star.frame.Desktop"), unoidl.com.sun.star.frame.XDesktop)
Dim xComponentLoader As unoidl.com.sun.star.frame.XComponentLoader = DirectCast(xDesktop, unoidl.com.sun.star.frame.XComponentLoader)
Dim arProps() As unoidl.com.sun.star.beans.PropertyValue = New unoidl.com.sun.star.beans.PropertyValue() {}
'Open XL
Dim xComponent As unoidl.com.sun.star.lang.XComponent = xComponentLoader.loadComponentFromURL(ConvertFile(XLFileLoc), "_blank", 0, arProps)
Dim ar() As unoidl.com.sun.star.beans.PropertyValue = New unoidl.com.sun.star.beans.PropertyValue(1) {}
ar(0) = New unoidl.com.sun.star.beans.PropertyValue()
ar(0).Name = "FilterName"
ar(0).Value = New uno.Any("calc_pdf_Export")
Dim xDispatcher As unoidl.com.sun.star.frame.XDispatchHelper
[b]xDispatcher.executeDispatch(xComponent, ConvertFile(PDFFileName), "", "", ar)[/b]
xDesktop.terminate()
Catch XLError As System.Exception
MsgBox(XLError.Message)
End Try
End Sub
Private Function ConvertFile(ByVal cvrFilePath As String) As String
Return "file:///" & cvrFilePath
End Function
Code: Select all
xDispatcher.executeDispatch(xComponent, ConvertFile(PDFFileName), "", "", ar)