Help!!! From form field to Word field 
Author Message
 Help!!! From form field to Word field

Some help please!!! I'm really a VB dummie!!!
I've already created an AutoExec macro in a Word template that displays a
form...
Now, how do I put the entered data in a Word field after pressing a command
button in the form???
Thanks!


Tue, 30 Jul 2002 03:00:00 GMT  
 Help!!! From form field to Word field
Hi Vampire,

Insert bookmarks into your template at the locations where you want the
information to appear and then use the following command in the
CommandButton Click event:

With ActiveDocument
    .Bookmarks("Bookmark1").Range.InsertBefore TextBox1
    .Bookmakrs("Bookmark2").Range.InsertBefore TextBox2

    Etc.

End With

Hope this helps,
Doug Robbins - Word MVP
Please post any follow-up to the Newsgroups so that others may benefit
therefrom or contribute thereto.

Quote:
> Some help please!!! I'm really a VB dummie!!!
> I've already created an AutoExec macro in a Word template that displays a
> form...
> Now, how do I put the entered data in a Word field after pressing a
command
> button in the form???
> Thanks!



Wed, 31 Jul 2002 03:00:00 GMT  
 Help!!! From form field to Word field

Quote:
> Hi Vampire,

> Insert bookmarks into your template at the locations where you want the
> information to appear and then use the following command in the
> CommandButton Click event:

> With ActiveDocument
>     .Bookmarks("Bookmark1").Range.InsertBefore TextBox1
>     .Bookmakrs("Bookmark2").Range.InsertBefore TextBox2

>     Etc.

> End With

> Hope this helps,
> Doug Robbins - Word MVP

YESSS!!! It works!!!
Thank you very much!
But now I have another problem...
I want to give the user the option of correcting information!
When I run the code for the first time I'll get bookmark: TextBox1 as I
want.
But when I run it again I'll get it obviously inserted like Bookmark:
textbox1textbox1.
Now, how can I clear the bookmark contents before the new insertion?


Fri, 02 Aug 2002 03:00:00 GMT  
 Help!!! From form field to Word field
Hi Pete,

1) You need to create [content] bookmarks, rather than Ilocation point
bookmarks. Select something (placeholder text, for instance), then
Insert/Bookmark.

2) Use this code to put information into the bookmark:

Sub InsertInfoAtBkmk()
    Dim rngBkm As Word.Range
    Dim BkmName As String

    BkmName = "Test"
    If ActiveDocument.Bookmarks.Exists(BkmName) Then
        Set rngBkm = ActiveDocument.Bookmarks(BkmName).Range
        rngBkm.Text = "Test"
        ActiveDocument.Bookmarks.Add Name:=BkmName, _
            Range:=rngBkm
    End If
End Sub

Quote:
> I want to give the user the option of correcting information!
> When I run the code for the first time I'll get bookmark: TextBox1 as I
> want.
> But when I run it again I'll get it obviously inserted like Bookmark:
> textbox1textbox1.
> Now, how can I clear the bookmark contents before the new insertion?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)



Fri, 02 Aug 2002 03:00:00 GMT  
 Help!!! From form field to Word field
Hi Pete,

Try the following. It *replaces* the bookmark with your text, then
re-creates the bookmark around the text.

---------------------------------------------------------

Dim myRange As Range

With ActiveDocument
    Set myRange = .Bookmarks("Bookmark1").Range
    myRange.Text = TextBox1.Text
    .Bookmarks.Add "Bookmark1", myRange
End With

---------------------------------------------------------

Hope this helps.
Regards
ibby

Please post any replies to the **newsgroup** so that others in the newsgroup
may contribute or benefit.


| > Hi Vampire,
| >
| > Insert bookmarks into your template at the locations where you want the
| > information to appear and then use the following command in the
| > CommandButton Click event:
| >
| > With ActiveDocument
| >     .Bookmarks("Bookmark1").Range.InsertBefore TextBox1
| >     .Bookmakrs("Bookmark2").Range.InsertBefore TextBox2
| >
| >     Etc.
| >
| > End With
| >
| > Hope this helps,
| > Doug Robbins - Word MVP
|
| YESSS!!! It works!!!
| Thank you very much!
| But now I have another problem...
| I want to give the user the option of correcting information!
| When I run the code for the first time I'll get bookmark: TextBox1 as I
| want.
| But when I run it again I'll get it obviously inserted like Bookmark:
| textbox1textbox1.
| Now, how can I clear the bookmark contents before the new insertion?
|
|



Sat, 03 Aug 2002 03:00:00 GMT  
 Help!!! From form field to Word field
It works!!!
Thank you all!!!


Sat, 03 Aug 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. How do I make form fields in a Word 97 Form required

2. Help dividing a multi-word DB field with changing word lengths into sections

3. Read HTML formatted data from database field, Insert Wordmerge fields, and save as Word document

4. Populate form fields from email Fields

5. on entry form text field macro - year field

6. Problem when unprotecting a document with form field text fields

7. Word Form Fields - mylabels.doc (0/1)

8. URGENT: Error when assigning long strings to Form Fields in a protected Word document

9. Form fields in Word

10. Word form template, start field and tab order

11. Setting the result of a form field in Word - Error

12. VB Function & Word Text Form Field

 

 
Powered by phpBB® Forum Software