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

read out field and write into external text-document

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


Joined: 10 May 2005
Posts: 6

PostPosted: Wed Jun 08, 2005 1:32 am    Post subject: read out field and write into external text-document Reply with quote

Hi,

is it possible to read out a field of a StarOffice8 XML form and write it than into a simple external text document?

I am new to StarOffice/OO and never did any macro-programming.

Is it possible to write into an external text-document? And if so, how may I realize it?

Thx

maxwell
Back to top
View user's profile Send private message
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Wed Jun 08, 2005 1:51 am    Post subject: Reply with quote

Yes, writing text to a text document with a macro is possible.

But I'm not familiar with the term "StarOffice8 XML form". Please explain.
_________________
Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs
Back to top
View user's profile Send private message Visit poster's website
maxwell
General User
General User


Joined: 10 May 2005
Posts: 6

PostPosted: Wed Jun 08, 2005 3:20 am    Post subject: XML Form Document Reply with quote

I use the StarOffice8 beta version.
When I create a new document, I can choose between writer, calc, ... , ... XML Form Document, ...
I only have the German version so I am not sure how it is called in the English verison.

By choosing the XML-Form Document, I have the possibility to create fields, check-box,...

It should be in OpenOffice too...
Back to top
View user's profile Send private message
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Wed Jun 08, 2005 3:41 am    Post subject: Reply with quote

I understand.
But sorry, I did no programming of OOo V2 (beta) by now.
_________________
Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs
Back to top
View user's profile Send private message Visit poster's website
maxwell
General User
General User


Joined: 10 May 2005
Posts: 6

PostPosted: Wed Jun 08, 2005 3:52 am    Post subject: Reply with quote

Thanks for helping me...

lets assume that I do have a table in my writer document and I want to write the table entries into an external txt-document.

How could I realize that?
Back to top
View user's profile Send private message
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Wed Jun 08, 2005 12:07 pm    Post subject: Reply with quote

Example for getting a string from a cell in a texttable, found:
http://www.oooforum.org/forum/viewtopic.phtml?t=16090&highlight=texttable

Code:

' first table
oTable = ThisComponent.getTextTables().getByIndex(0)
' first column and row
oCell = oTable.getCellByPosition(0, 0)
' show cell string
Msgbox oCell.String


Example of creating a new document, inserting text and saving (as OOo writer document and as plain text file)
Code:

Dim aNoArgs()

oDesktop = createUnoService("com.sun.star.frame.Desktop")
sNeueURL = "private:factory/swriter"
oDokument = oDesktop.loadComponentFromURL( sNeueURL, "_blank" , 0, aNoArgs())

' füllen mit Text
oText = oDokument.getText()
oCursor = oText.createTextCursor()

With oText
   .insertString(oCursor, "Testtext" , FALSE )
   .insertControlCharacter(oCursor, _
     com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
End With

cText = "Dies ist nur eine Testausgabe, Nr. "

for ii = 1 to 10
   sText = cText & ii
   With oText
      .insertString(oCursor, sText , FALSE )
      .insertControlCharacter(oCursor, _
        com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, False)
   End With
next ii

' speichern
sURL = ConvertToURL("/zentrale/firma/oo/test/generierterText.sxw")
oDokument.StoreToURL( sURL , aNoArgs() )

' exportieren als txt
Dim aMyArgs(1) as new com.sun.star.beans.PropertyValue
aMyArgs(0).Name = "FilterName"
aMyArgs(0).Value = "Text"

sURL = ConvertToURL("/zentrale/firma/oo/test/generierterText.txt")
oDokument.StoreToURL( sURL , aMyArgs() )

oDokument.Close(TRUE)

End Sub

Both are working examples (version: see footer)

HTH
_________________
Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs
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