Attribute VB_Name = "HS2_2_HS3" 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 Const REF_COL = 1 Const NAME_COL = 5 Const LOCATION_COL = 6 Const LOCATION2_COL = 7 Const IOMISC_COL = 12 Public Sub produce_ini_file_REFCOM_input() Const sFileName = "HS2_2_HS3.ini" Dim Row As Integer Dim sSection As String Dim sKey As String Dim sValue As String Sheet1.Activate Row = 2 Do While Cells(Row, 1) <> "" If Not Cells(Row, IOMISC_COL).EntireRow.Hidden Then Call WriteINIFile(Cells(Row, IOMISC_COL), "HS2Ref", Cells(Row, REF_COL), sFileName) ' HS2ref Call WriteINIFile(Cells(Row, IOMISC_COL), "Name", Cells(Row, NAME_COL), sFileName) ' name Call WriteINIFile(Cells(Row, IOMISC_COL), "Location", Cells(Row, LOCATION_COL), sFileName) ' location Call WriteINIFile(Cells(Row, IOMISC_COL), "Location2", Cells(Row, LOCATION2_COL), sFileName) ' location2 End If ' Next Row = Row + 1 Loop MsgBox "Done! " & vbCrLf & vbCrLf & "Now you should copy your file from c:\windows\" & sFileName & vbCrLf & "to: Your HS3 Server 'C:\Program Files (x86)\HomeSeer HS3\Config'" End Sub Sub WriteINIFile(ByVal sSection As String, ByVal sKey As String, ByVal sValue As String, ByVal sFileName As String) sSection = Replace(sSection, "[", "(") sSection = Replace(sSection, "]", ")") If WritePrivateProfileString(sSection, sKey, sValue, sFileName) <> 1 Then MsgBox "Error writing to file:" & sFileName End If End Sub