Consulting

Results 1 to 2 of 2

Thread: Loading values from an external file

  1. #1
    VBAX Newbie
    Joined
    Jul 2008
    Location
    Meblourne Australia
    Posts
    1
    Location

    Loading values from an external file

    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

  2. #2
    VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    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/show...fpart=all&vc=1
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •