| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Tue Sep 16, 2003 4:37 am Post subject: oDoc.Text gives me an error |
|
|
hi,
i can't execute this code in openoffice macros. This always gives me an error called property or method not found. Because of this error i couldn't use the function text cursor. Further, I would like to know how to find a cell in a sheet that is filled with a particular color( like yellow, red, etc.,.
oDesktopc = createUnoService("com.sun.star.frame.Desktop")
oDocc= oDesktopc.getCurrentComponent()
Dim oTextc As Object
oTextc = oDocc.Text 'her i get the error property or method not found.
oCursor = oText.createTextCursor()
Thanks,
Regards,
Raghu |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Tue Sep 16, 2003 6:16 am Post subject: |
|
|
| Quote: | | Because of this error i couldn't use the function text cursor. |
You are not clear on what type of document you are trying to work with. I'm assuming that it is a Writer (text) document.
I looked it up in the API. On a text document you can definitely call getText() to return an XText interface, which then leads to the method to create the cursor. Basic has some shortcuts, such as allowing you to access a property name that is really a method. Any method named oObj.getFooBar() can be accessed as though it were a property oObj.FooBar. Similarly, if there is a oObj.setFooBar( ... ) method, you can instead do assignment to the fake "property" as in oObj.FooBar = .....
You should be able to access the Text property (actually getText method) unless the document you have is not really a text document. Are you sure it is? You are getting it using getCurrentComponent, so is the current component something other than a text document?
In basic you could use ThisDocument to refer to the document from which the macro is running. Or you could get the desktop object, and then iterate through all of the open documents, looking for one with a specific name to make sure you have the right one.
| Quote: |
Further, I would like to know how to find a cell in a sheet that is filled with a particular color( like yellow, red, etc.,.
|
The idea would be to start with the spreadsheet document. Iterate over all of the cells, examine the color of each cell to see if it is sufficiently close to the color you are looking for. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| 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
|