Delimitador TAB archivo plano
Publicado por Pablo (35 intervenciones) el 12/05/2008 18:52:03
Buenas tardes, tengo un problemita... a ver si me pueden ayudar... tengo una aplicacion para abrir archivos planos, ya sean delimitados por coma, punto y coma etc.. el problema esta en que cuando quiero abrir un archivo delimitado por (tab) me arroja el siguiente error (runtime error - 2147467259 "valor en la clave excel de la seccion Engines no valido del registro de windows)...
estuve investigano pero no encontr nada les el codigo de la funcion con la que modifico el registro segun el tipo de delimitador del archivo que voy abrir.
Private Sub Command2_Click()
If Text1.Text = "" Then
MsgBox "Debe seleccionar algun archivo", vbInformation, "IMPORTANTE"
Exit Sub
End If
If Optcoma.Value = True Then
delim = ";"
End If
If Optpuntocoma.Value = True Then
delim = ";"
End If
If Opttab.Value = True Then
delim = "TabDelimited"
End If
If Optotro.Value = True Then
delim = Text4.Text
End If
sSep = "Delimited(" & delim & ")"
ModifRegistro HKEY_LOCAL_MACHINE, "SOFTWAREMicrosoftJet4.0EnginesText", "Format", sSep
conectar
End Sub
este es el llamado a la funcion y en la variable delim almaceno el valor (segun el tipo de archivo) para modificar el registro.
esta es la funcion:
Option Explicit
Dim delim As Variant
Public sSep As String
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
'''''''''''''*************Funcion para tratar el delimitador**********''''''''''''''''
Sub ModifRegistro(HKLM As Long, sPath As String, sClave As String, sValor As String)
Dim lRet As Long, hKey As Long
lRet = RegCreateKey(HKLM, sPath, hKey)
lRet = RegSetValueEx(hKey, sClave, 0, REG_SZ, ByVal sValor, Len(sValor))
lRet = RegCloseKey(hKey)
End Sub
con la coma y el punto y coma anda barbaro perocuando modifico a TabDelimited, me tira el error que mencione antes.
Agradesco su ayuda.
estuve investigano pero no encontr nada les el codigo de la funcion con la que modifico el registro segun el tipo de delimitador del archivo que voy abrir.
Private Sub Command2_Click()
If Text1.Text = "" Then
MsgBox "Debe seleccionar algun archivo", vbInformation, "IMPORTANTE"
Exit Sub
End If
If Optcoma.Value = True Then
delim = ";"
End If
If Optpuntocoma.Value = True Then
delim = ";"
End If
If Opttab.Value = True Then
delim = "TabDelimited"
End If
If Optotro.Value = True Then
delim = Text4.Text
End If
sSep = "Delimited(" & delim & ")"
ModifRegistro HKEY_LOCAL_MACHINE, "SOFTWAREMicrosoftJet4.0EnginesText", "Format", sSep
conectar
End Sub
este es el llamado a la funcion y en la variable delim almaceno el valor (segun el tipo de archivo) para modificar el registro.
esta es la funcion:
Option Explicit
Dim delim As Variant
Public sSep As String
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
'''''''''''''*************Funcion para tratar el delimitador**********''''''''''''''''
Sub ModifRegistro(HKLM As Long, sPath As String, sClave As String, sValor As String)
Dim lRet As Long, hKey As Long
lRet = RegCreateKey(HKLM, sPath, hKey)
lRet = RegSetValueEx(hKey, sClave, 0, REG_SZ, ByVal sValor, Len(sValor))
lRet = RegCloseKey(hKey)
End Sub
con la coma y el punto y coma anda barbaro perocuando modifico a TabDelimited, me tira el error que mencione antes.
Agradesco su ayuda.
Valora esta pregunta


0