Word Bookmarks, Userforms and Updates 
Author Message
 Word Bookmarks, Userforms and Updates

Hi All,

I am having an anoying problem.

I  have a user form which is used to add/update information in word
document.

There are 2 problems.

1. When I return the text contained in a bookmark I get the CR character at
the end or sometimes a sqaure box (i.e non characters).  how do i stop/fix
this ?

2.  As an alternative to using straight bookmarks I have used form fields in
my document.  This works great except for two things.

- after the fields are populated from the user form, I need to run a fields
update to update REF fields which relate to the Form Fields. but this makes
all the form fields blank (the user form is still open).  Any idease reasons
or improvement suggestions.

- when I return the field text to the user form it contains the FORMTEXT
before the actual text - can this be fixed.

Thanks



Wed, 30 Jul 2003 11:17:29 GMT  
 Word Bookmarks, Userforms and Updates

Quote:
> 1. When I return the text contained in a bookmark I get the CR
> character at the end or sometimes a sqaure box (i.e non characters).
> how do i stop/fix this ?

The square box is typically the end-of-cell marker for the contents
of a table cell.  You can fix it either by bookmarking only the cell
contents rather than the entire cell (not always easy to do), or by
reading the bookmark value into a variable and shortening it by one
character:  x = Left(x, Len(x) - 1)


--------------- "Life is nothing if you aren't obsessed." --John Waters
-----------------------------------------------------------------------



Wed, 30 Jul 2003 12:17:04 GMT  
 Word Bookmarks, Userforms and Updates
Hi Jason,

Quote:
> 1. When I return the text contained in a bookmark I get the CR character
at
> the end or sometimes a sqaure box (i.e non characters).  how do i stop/fix
> this ?

This can happen if there are paragraph marks in the text in the bookmark. If
you use Word 2000 use the Replace function to replace chr(13) with Chr(10),
which is a new line character

Quote:
> - after the fields are populated from the user form, I need to run a
fields
> update to update REF fields which relate to the Form Fields. but this
makes
> all the form fields blank (the user form is still open).  Any idease
reasons
> or improvement suggestions.

That's because your document is not protected. To reprotect use:
    activedocument.Protect type:=wdAllowOnlyFormFields,noreset:=true

Or, forget the protection and unlink the fields once you're done and before
you recalculate all the fields:
----------------------------------------------
Sub UnlinkFormfields()
Dim oField As Field

  For Each oField In ActiveDocument.Fields
    If oField.Type = wdFieldFormTextInput Then
      oField.Unlink
    End If
  Next
  Set oField = Nothing
End Sub

After running this code, recalculate all the other fields in the document:
    ActiveDocument.Fields.Update
----------------------------------------------
With you unlink a formfield, the field itself will be gone but the result
will be bookmarked so your ref fields will still be working

Quote:
> - when I return the field text to the user form it contains the FORMTEXT
> before the actual text - can this be fixed.

Is the document protected? Or this could have something to do with the way
you put the text into the fields. If the latter, could you show us the code
you're using?

Hope this helps,
regards,
Astrid

So that all can benefit from the discussion,
please post all followups to the newsgroup.

Visit the MVP Word FAQ site at http://www.mvps.org/word/
For direct access to all Microsoft newsgroups:



Wed, 30 Jul 2003 16:49:31 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Updating textboxes in Word using UserForms fields

2. Updating word bookmarks

3. Passing Userforms to subs (Word 2000 and 2002, I did not try Word 97)

4. Bookmarks, References and Userforms

5. userforms for bookmarks

6. UserForms, Textboxes & Bookmarks

7. bookmarks & userforms

8. Bookmarks in userforms, how do you populate more then one place

9. Help with Bookmarks and userforms

10. two questions on how to get data entries in userforms into bookmarks (if possible at all)

11. Check Boxes, Userforms Bookmarks

12. Office XP only: Spurious bookmark added to Word document Automating Powerpoint from Word

 

 
Powered by phpBB® Forum Software