Saving UserForm Selections for later use

D

DMS

All,

I am wondering if it is possible to save a users selections that they make
on a form so that the next time they use the form, their previous selections
are still made.

I am thinking that there has to be a way to read and srite from a text file
to get the options.

Thanks
 
D

DMS

JackD
Thanks for the response. I actually figured out another way to do it but I
am still having one problem.
The method I am using is to open a .csv file for Input. I then split the
..csv into variables. I then set the Object Values equal to the variables. I
also am able to write to the file when the settings change. The problem I am
having now is I don't know how to save the values for listBoxes with multiple
items selected. Any ideas.

Here is a portion of my code.

fnum = FreeFile

Open "C:\SaveSettingsTest.csv" For Input As #fnum
Do While Not EOF(fnum)
Line Input #fnum, Linez
SpLinez = Split(Linez, ",")

colText = SpLinez(0)
colOp1 = SpLinez(1)
colOp2 = SpLinez(2)
collst1 = SpLinez(3)
Loop

With UserForm2
.cm1.Value = colText
.op1.Value = colOp1
.op2.Value = colOp2
.lst1.Value = collst1
End With
 
J

JackD

First thing you have to do is figure out how you are going to read/store
those multiple values. Depending on the place in the CSV won't work because
you may have more things in there.

Maybe structure your CSV file so it has some tags in it:

[coltext]
blah
[ColOp1]
foo
bar
[ColOp2]
snipe
[Collst]
dippity
doo
dah

And parse the file line by line.
Write it out the same way.

For i = 0 To (Listbox1.Listcount - 1)
If ListBox1.Selected(i) = True Then
'write to the file here
End If
Next i

Setting the selections would be similar.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top