| View previous topic :: View next topic |
| Author |
Message |
tjeanneret Newbie

Joined: 03 Mar 2009 Posts: 3
|
Posted: Tue Mar 03, 2009 1:26 pm Post subject: In Writer modifying the content of a field through BASIC |
|
|
Hello everybody,
I need your help. I want to modify by program the content of fields that I define myself in a document. One of these fields may be named "ClientName" for exemple. I have a dialog box allowing me to type it in, among other informations.
I am able to access to the entered value in BASIC, I can display it in an MsgBox and modify it in its original location. But I am unable to modify my "ClientName" variable in my document (say an invoice).
In my writer document I have tried to define a Field of type TEXT named ClientName, than I have tried to access it through the following code, but this didn't work.
CtlFrm = Form.getByName("ClientName")
CtlFrm.Text = Txt
Could someone give me a clue about this ?
Thanks in advance,
Thierry |
|
| Back to top |
|
 |
probe1 Moderator


Joined: 18 Aug 2004 Posts: 2465 Location: Chonburi Thailand Asia
|
Posted: Wed Mar 04, 2009 2:09 am Post subject: |
|
|
You have defined a document variable (Insert>Fields...>Others...>Variables>Userfield)?
| Code: |
oDok = ThisComponent
oFelder = oDok.getTextFieldMasters()
oFeld = oDok.getTextFieldMasters().getByName( "com.sun.star.text.FieldMaster.User.ClientName" )
oFeld.Content = "myNewValue" |
Does this help? _________________ Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs |
|
| Back to top |
|
 |
tjeanneret Newbie

Joined: 03 Mar 2009 Posts: 3
|
Posted: Wed Mar 04, 2009 7:06 am Post subject: Yesss ! |
|
|
Thank you Winfried,
This is a first step in the right direction. My main concern is still to find my path through the documentation. I find it very tricky to use, and I find the lack of exemples a great problem.
For exemple, in the present case, I had a "Variable" defined instead of "User Field", and this does not work. I cannot figure out how to reach the content of my Variable, and where I can find this information.
It's too bad, because I like OpenOffice very much but I am facing a lot of problems while trying to go a bit further than what is given in the menu tree. On this particular point M$ has done a good job with their Office suite and VBA help. And God I don't like M$ !
Anyway thanks a lot, all the best to you,
Thierry |
|
| Back to top |
|
 |
probe1 Moderator


Joined: 18 Aug 2004 Posts: 2465 Location: Chonburi Thailand Asia
|
Posted: Thu Mar 05, 2009 1:04 am Post subject: Re: Yesss ! |
|
|
| tjeanneret wrote: | | For exemple, in the present case, I had a "Variable" defined instead of "User Field", and this does not work. I cannot figure out how to reach the content of my Variable, and where I can find this information. |
Thierry,
I hadn't this information present .... so I tested ...
New Writer document > Insert > Fields... > User field
Give the name "ClientName" and a value BLA
Then run the
| Code: | oDok = ThisComponent
oFelder = oDok.getTextFieldMasters()
xray oFelder |
Running the code shows me:
4 | String : "com.sun.star.text.fieldmaster.User.ClientName"
xray is a must! You'll find it here (on sourceforge)
And now my sorry:
doing the same with a user defined variable (named: "CN") I can access the object, but have no glue how to get the content...
| Code: | oFeld = oDok.getTextFieldMasters().getByName( "com.sun.star.text.fieldmaster.SetExpression.CN" )
xray ofeld |
Maybe you'll find something googling for "SetExpression"
Good luck! _________________ Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs |
|
| Back to top |
|
 |
tjeanneret Newbie

Joined: 03 Mar 2009 Posts: 3
|
Posted: Thu Mar 05, 2009 4:10 am Post subject: We are on the same track ! |
|
|
Winfried,
Yesterday I found the XRay macro, and I agree with you, it is an absolute MUST. But anyway I was in the same deadend as you with this particular problem.
I have found a reference to a GetExpression method (?) at :
com.sun.star.text.TextField,
but I simply don't know how to use it ! It seems that it could be possible to access to its "Content" property, but I cannont figure how. I am desesperated !
Thanks anyway, best regards,
Thierry _________________ Thierry Jeanneret
Couleur des Mers SaRl |
|
| 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
|