I'm doubting this is possible but this is what the boss man wants:
We have a userform on top of a document template that I've created where we
input data in the userform and it gets dumped into the document where it is
calculated, saved and printed, end of story.
part of what we enter (into the userform) is worker's comp descriptions and
classification codes. For example
8810 - Clerical Office Employee NOC
or
8742 - Outside Sales
Basically the question is, is it possible to have VB "remember" our inputs
and automatically fill the fields the next time we open the document and
input the next client?
I'm very much doubting it, but he makes me ask these things. :-)
Jonathan West - 06 Oct 2006 18:32 GMT
> I'm doubting this is possible but this is what the boss man wants:
>
[quoted text clipped - 19 lines]
>
> I'm very much doubting it, but he makes me ask these things. :-)
Its perfectly possible. When the userform is filled out, you have to store
the inputs someplace. Next time you start the form, retrieve the inputs &
populate the form with them, so the user can then change whatever he wants.
Rinse & repeat.
Where you store the inputs depends on whatever is convenient to you. Could
be a text file, an INI file or maybe the registry.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Helmut Weber - 06 Oct 2006 18:49 GMT
Hi Angyl,
HTH
You have to store the data somewhere,
that is, e.g. write them to a file
or to the registry, which is a file also,
and read them back when it is required.
Sure, it can be done.

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Jay Freedman - 06 Oct 2006 18:52 GMT
Yes, it's possible. The general idea is that the same procedure in the
userform's code that dumps the data into the document also writes the same
data to someplace else -- probably a text file in a predetermined folder,
but you could also use the registry if there isn't a lot of data. The
initialization procedure of the userform looks for that file or registry
key, and uses its data if found; otherwise it uses some hardcoded default
set of data.
I can't be specific without knowing the structure of your userform, but
here's a simple example for just a single text field:
Const dataFile = "C:\Documents and Settings\data.txt"
Private Sub cmdOK_Click()
Dim myRg As Range
On Error GoTo ErrHdl
Set myRg = ActiveDocument.Bookmarks("dataHere").Range
myRg.Text = TextBox1.Text
ActiveDocument.Bookmarks.Add Name:="dataHere", Range:=myRg
Open dataFile For Output As #1
Print #1, TextBox1.Text
Close #1
ErrHdl:
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim dataLine As String
On Error GoTo NoFile
Open dataFile For Input As #1
Line Input #1, dataLine
Close #1
TextBox1.Text = dataLine
Exit Sub
NoFile:
TextBox1.Text = "Default text"
End Sub
Set the path to the data file appropriately. If it's on the local machine,
it will be specific to each machine (or you could put it in a specific
user's profile to make it specific to that user, if the machine has multiple
profiles). You could try putting in on a share to make it available to
everyone, but then you run a small risk of collisions if two people try to
update it at the same moment.

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
> I'm doubting this is possible but this is what the boss man wants:
>
[quoted text clipped - 16 lines]
>
> I'm very much doubting it, but he makes me ask these things. :-)
Angyl - 10 Oct 2006 17:46 GMT
Thanks, y'all! That's great stuff.
> I'm doubting this is possible but this is what the boss man wants:
>
[quoted text clipped - 16 lines]
>
> I'm very much doubting it, but he makes me ask these things. :-)