Hola!!
Aqui tienes una Sub:
Código vb:
Ver originalPrivate Sub Divide_Archivo()
Dim Data, I As Double
Dim myArrayCampos() As String, myArrayValores() As String
Dim strTabla As String, strInsert As String, strCampo As String, strValor As String
Open App.Path & "\test.txt" For Input As #1
Do While EOF(1) = False
Line Input #1, Data
myArrayCampos() = Split(Mid(Data, InStr(1, Data, "{") + 1, _
InStr(1, Data, "}") - InStr(1, Data, "{") - 1), "|")
myArrayValores() = Split(Mid(Data, InStr(1, Data, "}") + 17, _
(Len(Data)) - (InStr(1, Data, "}") + 17)), "|")
Loop
Close #1
'=COMO ACCEDER A LOS CAMPOS======================================================
' For I = 0 To UBound(myArrayCampos)
' Debug.Print myArrayCampos(I)
' Next
'=COMO ACCEDER A LOS VALORES=====================================================
' For I = 0 To UBound(myArrayValores)
' Debug.Print myArrayValores(I)
' Next
'=GENERACION DE LA INSTRUCCION "INSERT"==========================================
strTabla = "TABLA_CLIENTES" 'NOMBRE DE LA TABLA
strInsert = "INSERT INTO " & strTabla & " ("
For I = 0 To UBound(myArrayCampos)
strCampo = strCampo & myArrayCampos(I) & ","
Next
strCampo = Mid(strCampo, 1, Len(strCampo) - 1)
strInsert = strInsert & strCampo & ") VALUES ("
For I = 0 To UBound(myArrayValores)
If I = 1 Then
strValor = strValor & "'" & myArrayValores(I) & "',"
Else
strValor = strValor & myArrayValores(I) & ","
End If
Next
strValor = Mid(strValor, 1, Len(strValor) - 1)
strInsert = strInsert & strValor & ")"
'MOSTRAR LA INSTRUCCION "INSERT"
MsgBox strInsert
End Sub
Private Sub cmd_Click()
Divide_Archivo
End Sub