Hi,
Can somebody help in separating Filename and Path when saving a file in a macro (excel).
Sub buclechupi333()
Dim TempFilePath As String
Dim i
MiFile = Application.GetOpenFilename(",*.xls")
If MiFile = False Then Exit Sub
'Here I have a path and filename (all together) and I can not separate it!
Sheets("1").Activate
For i = 1 To 15
TempFilePath = ActiveCell.Value
'So here it is duplicated because I can not dettach the filename from the path.
NewFile = "I:\Basura Temporal\" & TempFilePath & "\" & MiFile & ".xls"
If Dir(NewFile, vbArchive) <> "" Then Kill NewFile
ActiveWorkbook.SaveAs Filename:=NewFile
MsgBox NewFile
ActiveCell.Offset(1, 0).Select
Next i
ActiveWorkbook.Close SaveChanges:=False
End Sub
Thanks,
Can somebody help in separating Filename and Path when saving a file in a macro (excel).
Sub buclechupi333()
Dim TempFilePath As String
Dim i
MiFile = Application.GetOpenFilename(",*.xls")
If MiFile = False Then Exit Sub
'Here I have a path and filename (all together) and I can not separate it!
Sheets("1").Activate
For i = 1 To 15
TempFilePath = ActiveCell.Value
'So here it is duplicated because I can not dettach the filename from the path.
NewFile = "I:\Basura Temporal\" & TempFilePath & "\" & MiFile & ".xls"
If Dir(NewFile, vbArchive) <> "" Then Kill NewFile
ActiveWorkbook.SaveAs Filename:=NewFile
MsgBox NewFile
ActiveCell.Offset(1, 0).Select
Next i
ActiveWorkbook.Close SaveChanges:=False
End Sub
Thanks,