Results 1 to 3 of 3
  1. #1
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Folder location of INI file (2000+)

    I have an Excel workbook which is distributed to customers that requires a configuration/setup file to save and load variables to and from. These are typically 'last used' settings and using a simple text file - 'appname.ini' - I can successfully do what I want. The main advantage of this method is that I can adapt the workbook and re-issue it without the end user losing their personal settings.

    The question is, where do I store it?

    In testing, I am saving it in C:, but I have come across setups where access to the root of C: is not accessible to certain users.
    Would using the user's default 'My documents' folder be better?
    Would I be better off creating a folder in 'C:' or 'C:Program Files'?
    And I am not interested in learning how to save data to the registry - I've better things to do!

    If the INI file can't be found, or it is a first-time use, the file is created using default values, but it is where to save it that I would appreciate guidance on. It needs to be relatively accessible as it is possible the end user may want to change something in the INI file manually (e.g. using Notepad, to go into Debug or Engineer mode) which is an option I would not ordinarily want to make available.

    The workbook will typically be emailed to the end user and, depending on their self discipline, could be saved anywhere from their desktop to a memory stick. They may even run it directly from the email attachment...

    Advice appreciated!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Folder location of INI file (2000+)

    Saving data to the registry is *very* easy. For example:

    SaveSetting "LeifData", "Position", "Top", 300

    To retrieve the setting:

    Dim intTop As Integer
    intTop = GetSetting("LeifData", "Position", "Top", 100)

    The last argument in GetSetting is the default value to be used if the registry entry doesn't exist.

    Modifying the entries requires using RegEdit or VBA.

    If you prefer using an ini file, I'd store it in the user's default file location for Excel - this should always be available. The default file location is Application.DefaultFilePath so you can use something like

    Dim strPath As String
    Dim strIni As String
    strPath = Application.DefaultFilePath
    If Not Right(strPath, 1) = "" Then
    strPath = strPath & ""
    End If
    strIni = strPath & "LeifData.ini"

  3. #3
    Plutonium Lounger Leif's Avatar
    Join Date
    Dec 2000
    Location
    U.K.
    Posts
    14,010
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Folder location of INI file (2000+)

    Ooooh - 'very easy'...

    This needs looking at a bit more closely then!

    Thank you <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

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