I am trying to get the page count of a document (openoffice) using asp.net but am having trouble converting the object to a string or integer. My code is below so if anyone can please please help I'd really appreciate it (my head is sore from all the banging I've been doing!)
Thanks
Code: Select all
Dim oSM As Object 'Root object for accessing OpenOffice from VB
Dim oDesk, oDoc As Object 'First objects from the API
Dim oPageCount As Object
Dim _args As System.Array
Dim objDummy As Object = New Object
_args = System.Array.CreateInstance(objDummy.GetType, 0)
objDummy = Nothing ' free ressource
Try
oSM = CreateObject("com.sun.star.ServiceManager")
'Create the first and most important service
oSM.createInstance(com.sun.star.frame.Desktop)")
oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
'Open an existing doc (pay attention to the syntax for first argument)
oDoc = oDesk.loadComponentFromURL("file:///" & filetoCount, "_blank", 0, _args)
oPageCount = oDoc.createInstance("com.sun.star.text.TextField.PageCount")
[b]Dim tmp As Object
Dim tmp2 As String
tmp = oPageCount -- {System.__ComObject} i need to get the value that is stored in here to pass it back to the calling procedure????
tmp2 = tmp.ToString() [/b]
'Close the doc
oDoc.Close(True)
oDoc = Nothing
Return tmp2
:end
page = 1
while oDoc.jumptToNextPage
page = page + 1
loop
I just dont know how to program the while oDoc.jumptToNextPage bit - any ideas? I'd prefer to use the neater option in the Code above, but failing that??
Thanks for all help and hints