| View previous topic :: View next topic |
| Author |
Message |
Patrick9 General User

Joined: 30 Mar 2005 Posts: 8
|
Posted: Sun Apr 03, 2005 11:03 pm Post subject: Help with sbasic,please!! |
|
|
hi ,
I want to automate compare in SBasic.
I have this code:
'Creating service manager
Set objServiceManager = CreateObject("com.sun.star.ServiceManager")
'Creating a public object to use reflection for structured properties
Set objCoreReflection = objServiceManager.createinstance("com.sun.star.reflection.CoreReflection")
'Creating a Desktop to open files
Set Desktop = objServiceManager.createinstance("com.sun.star.frame.Desktop")
'Create the Dispatcher
Set Dispatcher = objServiceManager.createinstance("com.sun.star.frame.DispatchHelper")
'Open the file
Set Document1 = Desktop.loadComponentFromURL("file:///c:/a.doc", "_blank", 0, arg())
'Set the frame
Set Frame = Desktop.getCurrentFrame
'Set the arguments
Set CompParams(0) = OOoPropertyValue("InteractionHandler", False)
Set CompParams(1) = OOoPropertyValue("FileName", "file:///c:/b.doc")
Set CompParams(2) = OOoPropertyValue("CompareDocuments", True)
'Execute the comparison
Dispatcher.executeDispatch Frame, ".uno:CompareDocuments", "", 0, CompParams
////////////////
I want to compare automate this two documents but it open the window to select the second document to compare.
Some body can help me please???
And if somebody know how compare 2 documents with sbasic code without use the compare of openoffice,please send me please,because i need this two things because i want to open the comparator of openofice if previuslly i find some differences.
Thx for all! |
|
| Back to top |
|
 |
oopit General User

Joined: 22 Mar 2005 Posts: 7
|
Posted: Mon Apr 04, 2005 1:40 am Post subject: |
|
|
use URL instead of FileName, additionally, you will most likely have to wait for the 1st doc to load completelt before dispatching.
/ karl |
|
| Back to top |
|
 |
Patrick9 General User

Joined: 30 Mar 2005 Posts: 8
|
Posted: Tue Apr 05, 2005 12:03 am Post subject: Thx!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
|
Really thx,its run.
But now i have another ploblem,this code is to compare documents to see if there are differences,if its exists i lunch the openofficecomparator.
'Creating service manager
Set objServiceManager = CreateObject("com.sun.star.ServiceManager")
'Creating a Desktop to open files
Set Desktop = objServiceManager.CreateInstance("com.sun.star.frame.Desktop")
'Open the file
Set Doc1 = Desktop.loadComponentFromURL("///c:/a.sxc", "_blank", 0, arg())
Set Doc2 = Desktop.loadComponentFromURL("file:///c:/b.sxc", "_blank", 0, arg())
'i DONT KNOW HOW TO DO THIS PART,ALLWAYS GIVE ME THIS ERROR
set paragraphs_doc1 = Doc1.GetText().createEnumeration() 'RUNTIME ERROR 438: OBJECT DOES NOT SUPPORT THIS PROPERTY OR METHOD
Set paragraphs_doc2 = Doc2.Text.createEnumeration()'RUNTIME ERROR 438: OBJECT DOES NOT SUPPORT THIS PROPERTY OR METHOD
Do While (paragraphs_doc1.hasMoreElements() And paragraphs_doc2.hasMoreElements())
paragraph_doc1 = paragraphs_doc1.nextElement()
paragraph_doc2 = paragraphs_doc2.nextElement()
If (Not paragraph_doc1.supportsService("com.sun.star.text.TextTable") Or Not paragraph_doc2.supportsService("com.sun.star.text.TextTable")) Then
textenum_doc1 = paragraph_doc1.createEnumeration()
textenum_doc2 = paragraph_doc2.createEnumeration()
Do While (textenum_doc1.hasMoreElements() And textenum_doc2.hasMoreElements())
textrange_doc1 = textenum_doc1.nextElement()
textrange_doc2 = textenum_doc2.nextElement()
Loop
If (textrange_doc1 <> textrange_doc2) Then
' There is a textrange comparator
' have a look at the API for this
' Text ranges not equal
'return false
End If
End If
Loop
'return true
End Sub
It give me this error somebody know why??? |
|
| Back to top |
|
 |
pitonyak Administrator


Joined: 09 Mar 2004 Posts: 3618 Location: Columbus, Ohio, USA
|
Posted: Tue Apr 05, 2005 5:04 am Post subject: |
|
|
Are the documents properly loaded? You do not have a properly URL for Doc1, for example. Which property fails? Is either document NULL? | Code: | | If IsNull(Doc1) Then Print "Doc1 is NULL" | whill show you. _________________ --
Andrew Pitonyak
http://www.pitonyak.org/oo.php |
|
| Back to top |
|
 |
|
|
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
|