0

What i want : to a make a button that exports the selected data in this FelxGrid into .ini file format take (heights) as section and the others as values and keys , it dosen't have to be ini format it can also be something close to it

What i tried so far

Private Sub commandbutton_1()

Dim configfile As String
Dim myArray() As String 'i tried using arry but it didn't work 

configfile = "C:\" & "\CONFIGMEEE!.INI"


PutINISetting "", "", SettingsGrid.Clip, configfile


MsgBox "Exported.", vbInformation, "Settings"

SettingsGrid.SaveGrid configfile, flexFileTabText

What happened then the data we exported but not formatted at all as ini and written so :

enter image description here

Important to know

The flexgrid iam using is a vsflexgrid not an msflexgrid

And i am also using this as a MOUDLE

'API Function to write information to the INI File

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

'Get the INI Setting from the File
Public Function GetINISetting(ByVal sHeading As String, _
    ByVal sKey As String, _
    sINIFileName) As String

    Const cparmLen = 50
    Dim sReturn As String * cparmLen
    Dim sDefault As String * cparmLen
    Dim lLength As Long
    lLength = GetPrivateProfileString(sHeading, _
            sKey, _
            sDefault, _
            sReturn, _
            cparmLen, _
            sINIFileName)

    GetINISetting = Mid(sReturn, 1, lLength)
End Function

'Save INI Setting in the File
Public Function PutINISetting(ByVal sHeading As String, _
    ByVal sKey As String, _
    ByVal sSetting As String, _
    sINIFileName) As Boolean

    Const cparmLen = 50
    Dim sReturn As String * cparmLen
    Dim sDefault As String * cparmLen
    Dim aLength As Long
    aLength = WritePrivateProfileString(sHeading, _
        sKey, _
        sSetting, _
        sINIFileName)

    PutINISetting = True
End Function
StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
  • I think you are overwriting your ini formatted output with the saving of the grid data via `SettingsGrid.SaveGrid configfile, flexFileTabText` method call. Try commenting this line out and see if the ini file has the expected format and data. – MarkL Oct 25 '18 at 13:35
  • hey @MarkL , yes i did comment this line out, because this Method will take the whole grid not what i selected, otherwise this would work like magic , but sadly the SettingsGrid.SaveGrid configfile, flexFileTabText will only export the whole gird and you cannot select which cells or rows you want , i was thinking i do this with an arry , but how i do the Clip into an arry? that's what i am trying to know – PassionateCoder Oct 25 '18 at 13:49
  • 1
    I'm not currently familiar with that control or what the `Clip` property or method represents or does. But your current single call to `PutINISetting` isn't going to do what I believe you think it will. You need to call it multiple times, once for each line you are writing to the ini file. On each call you need to provide the heading and key value for the desired setting value. Right now, you're passing in empty strings for both the heading and key. You likely need to loop through the selected rows, writing each one separately to the ini file. – MarkL Oct 25 '18 at 14:39
  • @MarkL yeah i think thats the case there , Clip method takes the highlighted cells and then you can do what you want with them , i was thinking i can put them in a string and somehow format them as an ini data , – PassionateCoder Oct 26 '18 at 06:27

0 Answers0