| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Tue Apr 13, 2004 3:20 am Post subject: apply modifications TextFieldMaster |
|
|
Hi all,
I want to put a value on a Writer document. For this i use a textfieldmaster named var1.
I can modify the value of var1, but this modifications isn't apply in my document. So how i can apply the modification ?? (As button apply on the "insertfield" dilaogbox )
This is the code
| Code: |
vdoc = thisComponent
vEnum = vdoc.getTextFields().CreateEnumeration()
if isnull(vEnum) then
'msgbox "No Field"
else
MyString = ""
do while VEnum.hasMoreElements()
vVal = vEnum.nextElement
MyString = MyString + " " + vVal.TextFieldMaster.Name
if VVal.TextFieldMaster.Name = "Var1" then
VVal.TextFieldMaster.value = 3
end if
loop
end if
|
Thanks |
|
| Back to top |
|
 |
erikanderson3 OOo Advocate

Joined: 25 Feb 2004 Posts: 332 Location: San Francisco peninsula
|
Posted: Tue Apr 13, 2004 6:24 am Post subject: |
|
|
Just went over that a moment ago. Using the GUI, hit F9. To do it programatically, have a look at Thread # 4546. Look towards the bottom, and the second bar of code in a message from dfrench.
Cheers,
Erik |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Tue Apr 13, 2004 6:52 am Post subject: |
|
|
| Code: | Sub Main
oDoc = ThisComponent
oTextFields = oDoc.getTextFields()
oTextFieldEnum = oTextFields.createEnumeration()
Do While oTextFieldEnum.hasMoreElements()
oTextField = oTextFieldEnum.nextElement()
If oTextField.TextFieldMaster.Name = "Var1" Then
oTextField.TextFieldMaster.Value = Int( Rnd() * 1000 )
EndIf
Loop
oDocCtrl = oDoc.getCurrentController()
oDocFrame = oDocCtrl.getFrame()
oDispatcher = createUnoService( "com.sun.star.frame.DispatchHelper" )
oDispatcher.executeDispatch( oDocFrame, ".uno:UpdateFields", "", 0, Array() )
End Sub
|
I have never played with text fields in Writer before. So I found this an interesting learning experience.
Thanks erikanderson3 for the related post....
http://www.oooforum.org/forum/viewtopic.php?p=23229#23229 _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
dfrench Moderator

Joined: 03 Mar 2003 Posts: 1605 Location: Wellington, New Zealand
|
Posted: Tue Apr 13, 2004 3:49 pm Post subject: |
|
|
so embarrassing when horrible kludges one made in a hurry are quoted back as the way to do things
| Code: | | thiscomponent.getTextFields.refresh() | would replace all that stuff! |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Wed Apr 14, 2004 7:06 am Post subject: |
|
|
| dfrench wrote: | | Code: | | thiscomponent.getTextFields.refresh() | would replace all that stuff! |
Nice. I assume you mean would replace the dispatch stuff....
| Code: | oDocCtrl = oDoc.getCurrentController()
oDocFrame = oDocCtrl.getFrame()
oDispatcher = createUnoService( "com.sun.star.frame.DispatchHelper" )
oDispatcher.executeDispatch( oDocFrame, ".uno:UpdateFields", "", 0, Array() )
|
| dfrench wrote: | so embarrassing when horrible kludges one made in a hurry are quoted back as the way to do things |
Tell me about it.
The old version of MakePropertyValue() has probably been quoted all over the world by now. I have seen it show up a number of times. The old version uses the Dim statement to create a structure. (In my defense, at the time, I believed it was necessary to use the Dim statement when programming in OOo Basic.) _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
|