+ Reply to Thread
Results 1 to 7 of 7

Read and write INI files

  1. #1
    Registered User
    Join Date
    12-14-2007
    Location
    Georgia
    Posts
    78

    Read and write INI files

    Ok I have these ini files for a access control system. We have 40 different systems. All on different databases. that look like the following:
    Please Login or Register  to view this content.
    So I want to read these in to an excel sheet like I have attached. Sort them and purge them togeather. and then write the ini file back out to update the system. Thank you for your help.
    Attached Files Attached Files
    Excel 2007 SP1

  2. #2
    Valued Forum Contributor
    Join Date
    08-26-2006
    Location
    -
    MS-Off Ver
    2010
    Posts
    388

    Re: Read and write INI files

    Hi

    For reading the .ini files these Windows API functions could be useful:

    GetPrivateProfileSection
    GetPrivateProfileSectionNames
    GetPrivateProfileString

    and for writing:

    WritePrivateProfileSection
    WritePrivateProfileString

    There are plenty of examples on the www.

  3. #3
    Registered User
    Join Date
    12-14-2007
    Location
    Georgia
    Posts
    78

    Re: Read and write INI files

    yes I have seen some examples, but not sure how to loop thru them. Everthing I have seen pertains to getting a value that is known.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Read and write INI files

    Hello WHWALDREP,

    If you post a copy of your workbook in Excel 2003 format, I can help you with this.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    12-14-2007
    Location
    Georgia
    Posts
    78

    Re: Read and write INI files

    Thank you.
    Attached Files Attached Files

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Read and write INI files

    Hello WHWALDREP,

    I have written 2 macro modules. One contains the API calls for the Provate Profile functions and the second contains the "ReadINI" and "WriteINI" commands that are attached to the buttons. The code for this macros is below. For those who are interested about the Private Profile functions, download the the workbook and read the notes I have included in the module "Read_Write_INI_Files".

    You should know that init files typically don't use quotes as there are only 2 data types: Strings and Integers. The test file I created based on your example did not include the quotes. The empty line between sections was also removed as this doesn't conform to the API standard. It will read the information correctly, but the API WriteProfile functions don't include blanks between sections. Here is what the file looks like:

    [bInitialization File Layout[/b]
    Please Login or Register  to view this content.
    Macro Code to Read aand Write the Init File
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    12-14-2007
    Location
    Georgia
    Posts
    78

    Thumbs up Re: Read and write INI files

    Thank you for your help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1