Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reading from .INI file (VBA Excel 2000)

    I'm having trouble with the following code:

    Public Sub testINI()
    Const strSettingsFile As String = "D:mypathsettings.txt"
    Const strSection As String = "Formats"
    Dim strItem As String

    MsgBox Dir(strSettingsFile) 'File is found OK
    strItem = System.PrivateProfileString(strSettingsFile, strSection, "iLeader")
    <font color=red>' ** Runtime 424 - Object Required</font color=red>

    MsgBox "'" & strItem & "'"

    End Sub

    The settings.txt file contains the following:
    [Formats]
    Count=3
    iLeader=/
    iTrailer= min
    Item3=anything

    Do I need any particular References set in the VBE for the System.PrivateProfileString call to work? The iLeader and iTrailer values may have leading and/ or trailing spaces as part of their "string values". Is this permissable in this context?

    thanks

    Alan

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Reading from .INI file (VBA Excel 2000)

    Although PrivateProfileString may be available to Word VBA, it is not included with Excel VBA.

    However using some API code should solve the problem for you, and you may find some help here

    Andrew C

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading from .INI file (VBA Excel 2000)

    Thanks Andrew. That would explain it <img src=/S/grin.gif border=0 alt=grin width=15 height=15>. I'll give the API route a shot as you suggest.

    cheers

    Alan

Posting Permissions

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