View Single Post
 
Old 05-03-2025, 09:04 AM
Logit Logit is offline Windows 10 Office 2007
Expert
 
Join Date: Jan 2017
Posts: 587
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Here is a completely reworked version of the macro that successfully works :

Code:
Option Explicit

Sub myMacro()

Dim myFile As Object
Set myFile = CreateObject("Scripting.FileSystemObject")
Call myFile.CopyFile("C:\Users\logit\OneDrive\Desktop\Excel Repair\WinZip Registration.txt", "C:\Users\logit\OneDrive\Desktop\", True)

End Sub

Sub killFile()

Dim killFile As String
killFile = "C:\Users\logit\OneDrive\Desktop\Excel Repair\WinZip Registration.txt"

 Dim Msg As String, Title As String
  Dim Config As Integer, Ans As Integer
  Msg = "Are You Sure ?"
  Msg = Msg & vbNewLine & vbNewLine
  Msg = Msg & "Changes Cannot Be Undone."
 
  Title = "File Delete Critical !"
  Config = vbYesNo + vbCritical
  Ans = MsgBox(Msg, Config, Title)
  If Ans = vbYes Then
    If Len(Dir$(killFile)) > 0 Then
    SetAttr killFile, vbNormal
      Kill killFile
      Else
    MsgBox "File Not Found"
    End If
  End If
  
  If Ans = vbNo Then Exit Sub

End Sub
Reply With Quote