PDA

View Full Version : Loading values from an external file



jcrennan
07-29-2008, 10:27 PM
I am looking at ways to have deafault values that can be changed by users in a word Marco

I have been told to load some default (user dependant) values from another file into the macro. Just wondering how and the best way.

Was told have default values in the userform then check if a user default file exists and if it does load these values into the userform.

I have found the routine to check if the file exists.

What is the best way then to load these values into the user form

Also to match the other side of this how do I create the file if it doesnt exist and save the values into it?

If you have some sample code that would be appreciated.

or is there a better way?

Default Values text file Idea (maybe .csv)

Global Defaults
DefaultDirectory, C:\mypath\
DeafultFilename, myfile.txt
Tagnumber, #tag

Location Defaults
Location1, LocCode1, Fund1
Location2, LocCode2, Fund2
Location3, LocCode3, Fund3

Collection Deafults
Collection1, CollCode1, Budget1, Type1, Tag1
Collection2, CollCode2, Budget2, Type2, Tag2
Collection3, CollCode3, Budget3, Type3, Tag3
Collection4, CollCode4, Budget4, Type4, Tag4
Collection5, CollCode5, Budget5, Type5, Tag5

macropod
07-29-2008, 11:34 PM
Hi jcrennan,

Opening and reading a plain text file, and loadining values from it into an array is easy enough, but your file layout suggests the file is more like an INI file. For that, see:
http://www.wopr.com/cgi-bin/w3t/showflat.pl?Cat=&Board=vb&Number=719219&page=3&view=collapsed&sb=5&o=0&fpart=all&vc=1