Hi
I am having a bit of trouble with the below code. basically, I want it to move the open workbook from one folder to another. I probably need to add a activeworkbook.close before I can move it, but I'm not sure where.
any help would be appreciated.
Many thanks in advance
Private Sub CommandButton4_Click()
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:="123"
Dim msg, Msg1, Firstname As String, Ans, Ans1 As Variant
Dim spacepos As Integer
Dim Fullname, FromDir, ToDir, FileExt, FileNames As String
Dim fso As Object
Set fso = CreateObject("Scripting.Filesystemobject")
FromDir = "C:\documents\To be approved"
ToDir = "C:\documents\Approved (Excel)"
FileExt = ".xls"
Filename = Range("F41").Text & FileExt
Fullname = Range("D73").Text
spacepos = InStr(Fullname, " ")
Firstname = Left(Fullname, spacepos - 1)
msg = "Are you sure you want to approve, " & Firstname & "?"
Ans = MsgBox(msg, vbYesNo)
Select Case Ans
Case vbYes
Cells(73, 6).Value = Environ("USERNAME") & " " & Now
If Not cell = "" Then
cell.Locked = True
End If
Cells(73, 6).Locked = True
Application.ScreenUpdating = True
ActiveSheet.Protect Password:="123"
CommandButton4.Enabled = False
Case vbNo
GoTo Quit:
End Select
Msg1 = "Would you like to move this CR to the approved folder?"
Ans1 = MsgBox(Msg1, vbYesNo)
Select Case Ans1
Case vbYes
fso.MoveFile (FromDir & Filename), ToDir
Case vbNo
GoTo Quit
End Select
Quit:
End Sub
Bookmarks