If I'm understanding you correctly
Not much error checking, and the INI would probably have to be on shared server
Two different ways - singlely and a deliminated string
The second might be the one that works best for you (not sure)
Option Explicit
Private Declare Function GetPrivateProfileString Lib "kernel32" _
Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Public Const IniFileName As String = "C:\Users\Public\Documents\TemplateDefaults.ini"
Sub Demo()
Dim v As Variant
Dim i As Long
IniFileString("Authors", "Author01") = "Tom"
IniFileString("Authors", "Author02") = "Bill"
IniFileString("Authors", "Author03") = "Mary"
IniFileString("Departments", "Dept01") = "Sales"
IniFileString("Departments", "Dept02") = "Production"
IniFileString("Departments", "Dept03") = "Sourcing"
IniFileString("Products", "Food") = "Hot Dog;Chili;Chips;Cookies"
IniFileString("Products", "Drinks") = "Coke;Pepsi;Tab;Coffee;Tea"
MsgBox IniFileString("Authors", "Author02")
MsgBox IniFileString("Departments", "Dept03")
v = Split(IniFileString("Products", "Food"), ";")
For i = LBound(v) To UBound(v)
MsgBox v(i)
Next i
v = Split(IniFileString("Products", "Drinks"), ";")
For i = LBound(v) To UBound(v)
MsgBox v(i)
Next i
End Sub
Property Let IniFileString(ByVal Sect As String, ByVal Keyname As String, ByVal Wstr As String)
Dim cntChar As Long
cntChar = 0
If Len(Sect) = 0 Or Len(Keyname) = 0 Then
MsgBox "Section Or Key To Write Not Specified !!!", vbExclamation, "INI"
Exit Property
Else
cntChar = WritePrivateProfileString(Sect, Keyname, Wstr, IniFileName)
End If
End Property
Property Get IniFileString(ByVal Sect As String, ByVal Keyname As String) As String
Dim cntChar As Long
Dim RetStr As String * 128
Dim StrSize As Long
cntChar = 0
IniFileString = vbNullString
If Len(Sect) = 0 Or Len(Keyname) = 0 Then
MsgBox "Section Or Key To Read Not Specified !!!", vbExclamation, "INI"
Exit Property
Else
RetStr = Space(128)
StrSize = Len(RetStr)
cntChar = GetPrivateProfileString(Sect, Keyname, "", RetStr, StrSize, IniFileName)
If cntChar > 0 Then IniFileString = Left$(RetStr, cntChar)
End If
End Property