Problem With Code...Still
Precisely what does "doesn't work" mean? Is it throwing an error? If so,
what is the error message? If not, then what does it do, or not do? When I
looked at this before I could not ascertain what Filename1 equated to. To
my knowledge that still has not been revealed. Does it include the complete
path? You must remember that we cannot see your file so you must explain
the circumstances and define what your variables are if you expect useable
solutions.
"NFL" wrote in message
...
I posted a message earlier and been trying to figure out why this code
doesn't work right. Thank you for all your help.
Private Sub CommandButton6_Click()
Dim message As String
Set MyComputer = CreateObject("Scripting.FileSystemObject")
FolderName1 = Range("F6")
FileName1 = Range("M6")
If MyComputer.FolderExists(FolderName1) = False Then
message = MsgBox("The directory: " & FolderName1 & ", does not
exist." & Chr(10) _
& "Enter a new directory path (cell F6).", 0, "Not today my
friend.")
Else
If MyComputer.FileExists(FileName1) = True Then
message = MsgBox("The file name: " & FileName1 & ", already
exists." & Chr(10) _
& "A copy of this file has NOT been saved.", 0, "Not today my
friend.")
Else
Sheet18.Visible = xlSheetVisible
Sheets("Export").Copy
ActiveWorkbook.SaveAs Filename:=FileName1, FileFormat:=xlNormal
With Workbooks(FileName1).Sheets(1).Cells
.Value = .Value
End With
ActiveWindow.Close
End If
End If
End Sub
|