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

oDoc.Text gives me an error

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






PostPosted: Tue Sep 16, 2003 4:37 am    Post subject: oDoc.Text gives me an error Reply with quote

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
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Tue Sep 16, 2003 6:16 am    Post subject: Reply with quote

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
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Tue Sep 16, 2003 9:48 am    Post subject: Reply with quote

I confirm that if you lanch a writer document and then run your macro there is no problem with the line
Code:
oTextc = oDocc.Text 'her i get the error property or method not found.

but here is a problem with the next line and I don't kwnow why (I don't use the writer API)
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Tue Sep 16, 2003 9:55 am    Post subject: Text Reply with quote

The last line must be :
Code:
 oCursor = oTextc.createTextCursor()

You have forget the 'c' in oTextc
and then there is no more problem
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
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