richo120792
New Member
- Joined
- Jan 25, 2016
- Messages
- 12
Hello, I am having trouble with the next code, I want the Filename to be defined from a string variable which is received in the sub as Nombre_Archivld, but I can't get it to work, I am printing the variable in order to see if it has the correct information, and it had DTP.txt so it was supposed to work, but I know that the code is not working because of some data type error, because if I place Filename:=Filename instead of Filename:=nombre, the code works but the OLEObject does not gets the right name.
Sub carga_archivos_modulo(Nombre_Archivld) 'Declaration of the String received
Dim sFile As String
Dim nombre As String
Filename = Application.GetOpenFilename(FileFilter:=Filt, FilterIndex:=FilterIndex, Title:=Title)
isBool = VarType(Filename) = vbBoolean
If isBool Then If Not Filename Then Exit Sub
If Dir(Nombre_Archivld) <> "" Then
SetAttr Nombre_Archivld, vbNormal
Kill Nombre_Archivld
End If
sFile = Dir(Filename)
If sFile = "" Then
ExtFind = "No file"
Else
ExtFind = Right$(sFile, Len(sFile) - InStrRev(sFile, "."))
End If
nombre$ = Nombre_Archivld & "." & ExtFind
MsgBox nombre
ActiveSheet.OLEObjects.Add(Filename:=nombre, Link:=False, DisplayAsIcon:=True _
, IconFileName:=nombre, IconIndex:=0, IconLabel:=nombre).Select
' ActiveSheet.OLEObjects.Add(Filename:=strCompFilePath, Link:=False, DisplayAsIcon:=True _
' , IconFileName:=Filename, IconIndex:=0, IconLabel:=Filename).Select
End Sub
Thank you for the help.
Sub carga_archivos_modulo(Nombre_Archivld) 'Declaration of the String received
Dim sFile As String
Dim nombre As String
Filename = Application.GetOpenFilename(FileFilter:=Filt, FilterIndex:=FilterIndex, Title:=Title)
isBool = VarType(Filename) = vbBoolean
If isBool Then If Not Filename Then Exit Sub
If Dir(Nombre_Archivld) <> "" Then
SetAttr Nombre_Archivld, vbNormal
Kill Nombre_Archivld
End If
sFile = Dir(Filename)
If sFile = "" Then
ExtFind = "No file"
Else
ExtFind = Right$(sFile, Len(sFile) - InStrRev(sFile, "."))
End If
nombre$ = Nombre_Archivld & "." & ExtFind
MsgBox nombre
ActiveSheet.OLEObjects.Add(Filename:=nombre, Link:=False, DisplayAsIcon:=True _
, IconFileName:=nombre, IconIndex:=0, IconLabel:=nombre).Select
' ActiveSheet.OLEObjects.Add(Filename:=strCompFilePath, Link:=False, DisplayAsIcon:=True _
' , IconFileName:=Filename, IconIndex:=0, IconLabel:=Filename).Select
End Sub
Thank you for the help.