Results 1 to 11 of 11
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Editable replaces?! (WinXP/Word2003)

    I'm working on a project that, when finalised, will automatically enter a large amount of information from userforms (by search and replace, #date with the user's date) and will be protected to allow the user to enter other details him/herself through formfields.

    I would like therefore to enter the search and replace data by inserting a formfield and entering the text eg the date in that formfield, or alternatively have the original set up with empty formfields already there and have the search and replace populate the formfields rather than replace the existing text completely.

    A side problem is that some of the pages of the document will be repeated pastes of autotext entries containing the formfields, so I can't name them ahead of time in order to refer to them ...

    Can anyone tell me if this is possible?

    Many thanks
    Beryl M


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Editable replaces?! (WinXP/Word2003)

    I've read your post several times, but I don't understand it. You state that the form fields are intended to let the user enter information, yet you also want to search and replace them, it seems. Apart from that, I don't see how you could search for form fields if you don't know what they're called or what they contain.

    Could you try again?

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Editable replaces?! (WinXP/Word2003)

    Sorry, Hans, I'm not very good at explaining this sort of thing!

    Okay, what I have is a several-page, protected template, that will have other pages added, which currently contains:

    a) plain text markers (eg #date) which are replaced with text from userforms, and
    [img]/forums/images/smilies/cool.gif[/img] form fields that the user will tab through to fill in information.

    What I would like to be able to do is to make the text entered via the userforms editable (for the inevitable typos, changes of mind, etc), bearing in mind the document is protected.

    Can you suggest how I could do this?!

    I had thought either some way of filling existing userforms (difficult, as you say, since we won't have a name for them) or replacing the plain text markers with formfields, in which we'd put the text from the userforms, so the user is left with a document full of formfields, some filled by the userforms, the rest awaiting their input.

    I hope this makes better sense this time - I've just had my lunch so hopefully the refuelled mind is working a little more logically now!
    Beryl M


  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Editable replaces?! (WinXP/Word2003)

    Perhaps you could use the methods from the attachment to <post#=259,183>post 259,183</post#> - it employs a userform to set document variables, and the page header contains DOCVARIABLE fields that display the value of these variables (but these fields can be anywhere in the document. The user can reopen the userform at any time to edit the values of the document variables.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Editable replaces?! (WinXP/Word2003)

    Umm, yes, I used that method in a big project at my old job, but i was hoping for a method using the formfields ... do I take it that's not possible? Only I didn't want to keep the userform available - the logistics of repopulating the multiple-entry formfield (see <!post=post 567572,567572>post 567572<!/post> from this morning) gave me a headache from the moment I thought of it ...!
    Beryl M


  6. #6
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Editable replaces?! (WinXP/Word2003)

    Okay, another thought - if I create a new formfield in the middle of document full of other formfields, how do I refer to the one I just created?

    I was thinking of naming it immediately, or maybe specifying the content immediately, without moving away and therefore losing the reference, but Word only seems to allow specifying the range and type of it as it creates it ...?
    Beryl M


  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Editable replaces?! (WinXP/Word2003)

    Something like this?

    Dim ff As FormField
    Dim strText As String
    ' Normally, this would be set from the userform
    strText = "BerylM"
    ActiveDocument.Unprotect
    With Selection.Find
    .Text = "#Date"
    If .Execute Then
    Set ff = ActiveDocument.FormFields.Add( _
    Range:=Selection.Range, Type:=wdFieldFormTextInput)
    ff.Result = strText
    End If
    End With
    ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
    NoReset:=True

  8. #8
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Editable replaces?! (WinXP/Word2003)

    <img src=/S/hailpraise.gif border=0 alt=hailpraise width=27 height=22> <img src=/S/hailpraise.gif border=0 alt=hailpraise width=27 height=22> <img src=/S/hailpraise.gif border=0 alt=hailpraise width=27 height=22> Hans, you're a genius!! <img src=/S/hailpraise.gif border=0 alt=hailpraise width=27 height=22> <img src=/S/hailpraise.gif border=0 alt=hailpraise width=27 height=22> <img src=/S/hailpraise.gif border=0 alt=hailpraise width=27 height=22>

    (well, we knew that anyway, but you just proved it again!)

    I haven't tried it yet, but I can see it'll definitely work for what I want to do.

    Many thanks again!
    Beryl M


  9. #9
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Editable replaces?! (WinXP/Word2003)

    Hans, just a quick note re the formfield replace - how do I make it cycle through the document and change all instances? I've tried a couple of ways but nothing has worked so far ...?
    Beryl M


  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Editable replaces?! (WinXP/Word2003)

    The central part of the code could look like this:

    With Selection.Find
    .Text = "#Date"
    Do While .Execute
    Set ff = ActiveDocument.FormFields.Add( _
    Range:=Selection.Range, Type:=wdFieldFormTextInput)
    ff.Result = strText
    Loop
    End With

  11. #11
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Editable replaces?! (WinXP/Word2003)

    Thanks Hans. <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

    <img src=/S/sigh.gif border=0 alt=sigh width=15 height=15> I wish I could write code as simple - and simply effective - as yours!
    Beryl M


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •