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

apply modifications TextFieldMaster

 
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 Apr 13, 2004 3:20 am    Post subject: apply modifications TextFieldMaster Reply with quote

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
OOo Advocate


Joined: 25 Feb 2004
Posts: 332
Location: San Francisco peninsula

PostPosted: Tue Apr 13, 2004 6:24 am    Post subject: Reply with quote

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
View user's profile Send private message
DannyB
Moderator
Moderator


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

PostPosted: Tue Apr 13, 2004 6:52 am    Post subject: Reply with quote

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
View user's profile Send private message
dfrench
Moderator
Moderator


Joined: 03 Mar 2003
Posts: 1605
Location: Wellington, New Zealand

PostPosted: Tue Apr 13, 2004 3:49 pm    Post subject: Reply with quote

Embarassed 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
View user's profile Send private message
DannyB
Moderator
Moderator


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

PostPosted: Wed Apr 14, 2004 7:06 am    Post subject: Reply with quote

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:
Embarassed so embarrassing when horrible kludges one made in a hurry are quoted back as the way to do things


Tell me about it. Smile

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
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