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

[Solved] Placing text in a named section of a document

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


Joined: 24 Nov 2008
Posts: 45

PostPosted: Thu May 07, 2009 8:10 pm    Post subject: [Solved] Placing text in a named section of a document Reply with quote

Hi all,

I am bringing text in from a dialog and want to place it in a named section in a document. I'm not sure if the following tack is the right one:

Code:
   Dim oDoc as Object
   Dim oSections as Object
   Dim oSec as Object
   
   oDoc = thiscomponent
   oSections = oDoc.getTextSections
   oSec = oSections.GetByName("Instructions")
   oSec.Text = "Hello" '<-- Fails


Notably, the last line fails, since there is no ".Text" attribute of a section. Anyone have any ideas?

Thanks.
_________________
--Steve


Last edited by slang4201 on Fri May 08, 2009 6:31 am; edited 1 time in total
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3152
Location: Columbus, Ohio, USA

PostPosted: Thu May 07, 2009 9:15 pm    Post subject: Reply with quote

I do not know the answer, never done it, but

http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Text/Text_Sections

This uses a cursor to insert text content and such. To get into the section, they move the cursor back a paragraph.

You might be able to use the current controller to select the section or the anchor and then move the cursor into the section. i would try this, but I must go to bed...
_________________
--
Andrew Pitonyak
My Document: http://www.pitonyak.org/AndrewMacro.odt
Free Info: http://www.pitonyak.org/oo.php
Most hated bug: http://www.openoffice.org/issues/show_bug.cgi?id=84159
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
slang4201
General User
General User


Joined: 24 Nov 2008
Posts: 45

PostPosted: Fri May 08, 2009 6:30 am    Post subject: Reply with quote

I missed one small part, this now works:

Code:
Dim oDoc as Object
   Dim oSections as Object
   Dim oSec as Object
   
   oDoc = thisComponent
   oSections = oDoc.getTextSections
   oSec = oSections.GetByName("Instructions")
   oSec.Anchor.String = "Hello"


Thanks for the pointer to Anchor!
_________________
--Steve
Back to top
View user's profile Send private message
pitonyak
Administrator
Administrator


Joined: 09 Mar 2004
Posts: 3152
Location: Columbus, Ohio, USA

PostPosted: Fri May 08, 2009 1:04 pm    Post subject: Reply with quote

Interesting... I did not know that you could set text at an anchor.... Does that set the text into the section?
_________________
--
Andrew Pitonyak
My Document: http://www.pitonyak.org/AndrewMacro.odt
Free Info: http://www.pitonyak.org/oo.php
Most hated bug: http://www.openoffice.org/issues/show_bug.cgi?id=84159
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address
slang4201
General User
General User


Joined: 24 Nov 2008
Posts: 45

PostPosted: Fri May 08, 2009 1:14 pm    Post subject: Reply with quote

It does indeed. I haven't tested it with text already in the section to see if it replaces what is already there, though I suspect it does.
_________________
--Steve
Back to top
View user's profile Send private message
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