Group: microsoft.public.word.vba.general
From: =?Utf-8?B?QXNzb2NpYXRlcw==?=
Date: Sunday, April 13, 2008 3:54 AM
Subject: Re: retrieve data back to userform

Hi Doug,

Sorry, i'm still struggling to get it to work. What you have said and shown
are very clear to me but i don't understand why the { DOCVARIABLE test } did
not get replaced with the value of the Textvarname.

In the template .dot, i did ctrl + F9 and {} came out ready for me to enter
something inside it. So i typed in (in capital) { DOCVARIABLE test }. It was
highlighted when i clicked on it.

Anyway, in the userform, i have a textbox called txtvarname and a button
called "OK".

In the "OK" button, i have the codes you gave (a very simple test)
With ActiveDocument
MsgBox txtvarname.Text
.Variables("test").Value = me.txtvarname.Text
End With

me.hide ' hide the form

After i clicked "OK", that { DOCVARIABLE test } was still there. it didn't
change or get replaced. Then, i thought that this might be to do with the
template. Maybe it didn't work well with Template. I tested it with a normal
document and the result was still the same.

Sorry, i'm sure this should be a trivial case but don't understand why it
didn't work for me :(

I use office 03 by the way.

Thank you once again in advance


"Doug Robbins - Word MVP" wrote:

> With the cursor at the location in the document where you want the data to
> appear, Press Ctrl+F9 to insert a pair of field delimiters { } and inside
> them type DOCVARIABLE test
>
> { DOCVARIABLE test }
>
> You must use Ctrl + F9 to insert the { }
>
> Actually however if you toggle the display of the fields using Alt+F9 in the
> document that you already have, you will probably see the field that you
> inserted via the menu system
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Associates" wrote in message
> news:8148649D-93B5-4006-9DD6-0A061DD10773@microsoft.com...
> > Thank you Doug for your reply.
> >
> > This is what i'm after. However, because this is a new thing to me, I got
> > troubled implementing it. I have googled it and found the steps as below
> >
> > 1. On the Insert menu, click Field.
> > 2. In the Categories box, select Document Automation.
> > 3. In the Field names list, select DocVariable.
> > 4. In the New Name box, under Field properties, type the name of the
> > document variable.
> > 5. Click OK
> >
> > I put the cursor in the area where i want this {DOCVARIABLE "test"} to be
> > and followed the steps above. After clicking "OK" button, nothing happens.
> > I
> > don't see {DOCVARIABLE "test"} any where in the document. I wonder what
> > else
> > are missing here. I tried it a different way but to no avail :(
> >
> > I really appreciate your patience.
> >
> > Thank you in advance
> >
> > "Doug Robbins - Word MVP" wrote:
> >
> >> Instead of bookmarks, use { DOCVARIABLE varname } fields and then you set
> >> and get the data by using the .Value attribute of the variables.
> >>
> >> With ActiveDocument
> >> .Variables("varname").Value = txtvarname.Text
> >> etc
> >> End With
> >>
> >> and to retrieve the information, reverse the bits either side of the =
> >> sign.
> >>
> >> --
> >> Hope this helps.
> >>
> >> Please reply to the newsgroup unless you wish to avail yourself of my
> >> services on a paid consulting basis.
> >>
> >> Doug Robbins - Word MVP
> >>
> >> "Associates" wrote in message
> >> news:FBC705F6-9852-48D8-A8ED-4AB5CFFD44F6@microsoft.com...
> >> > Hi,
> >> >
> >> > I have a problem with bookmarks. I have a userform called "New
> >> > application
> >> > form" made up for a template .dot. In the word, i have insert bookmarks
> >> > that
> >> > correspond to the text fields in the userform. So, when user finishes
> >> > filling
> >> > out the fields and hit "OK" button, all the data are put into
> >> > bookmarks.
> >> >
> >> > However, what i'm trying to do now is to be able to retrieve all those
> >> > data
> >> > back from bookmarks to the form. I know the code to retrieve values
> >> > from
> >> > bookmarks to textfields in the userform. The reason for this is to
> >> > allow
> >> > user
> >> > to edit some of the data through the form. (don't know if by doing
> >> > this, i
> >> > have made my life more difficult). Anyway, i created another userform
> >> > called
> >> > "Editing application form" and a Edit button (use macro). So when user
> >> > clicks
> >> > on this button, it brings up the "Editing application form" with all
> >> > the
> >> > data
> >> > in their appropriate text fields.
> >> >
> >> > The problem here is When user hits "Edit now" button, i got error
> >> > message
> >> > saying
> >> > "The requested member of the collection doesn't exist". When i checked
> >> > the
> >> > bookmarks, those bookmarks are not there. I believe this is because
> >> > they
> >> > are
> >> > not entered in the first place during the creation of the new
> >> > application
> >> > form. (something new i learn again today)
> >> >
> >> > so is there any other ways that i could use apart from bookmarks and
> >> > still
> >> > helps resolve my issue?
> >> >
> >> > Thank you in advance
> >> >
> >> >
> >>
> >>
> >>
>
>
>

Safety Articles | Usenet Groups | Usenet News | Bluegrass