Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27

Thread: VBA Dir File Copy and Paste: Check if file exists then copy file from one directory to another. Bat File

  1. #21
    Junior Member
    Join Date
    Jul 2020
    Posts
    3
    Rep Power
    0
    Problem Solved

  2. #22
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0
    This Problem is not Solved, I have this macro & it works sometimes & sometimes it doesnt works
    Code:
    Public Declare PtrSafe Function ShellExecute _
        Lib "shell32.dll" _
        Alias "ShellExecuteA" ( _
        ByVal hwnd As Long, _
        ByVal lpOperation As String, _
        ByVal lpFile As String, _
        ByVal lpParameters As String, _
        ByVal lpDirectory As String, _
        ByVal nShowCmd As Long) _
    As Long
    
    
    Sub STEP2()
    Dim strFileName As String
    Dim strFileExists As String
     
        strFileName = "C:\Users\WolfieeeStyle\Desktop\Close Excel.lnk"
        strFileExists = Dir(strFileName)
     
       If strFileExists > "" Then
       Set fso = CreateObject("scripting.filesystemobject")
       fso.MoveFile Source:="C:\Users\WolfieeeStyle\Desktop\Close Excel.lnk", Destination:="C:\Users\WolfieeeStyle\Desktop\WolfieeeStyle\9.15\"
        ShellExecute 0, "OPEN", "C:\Users\WolfieeeStyle\Desktop\WolfieeeStyle\9.15\Close Excel.lnk", "", "", 1
        Else
            
        End If
        
    End Sub

  3. #23
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0
    Problem Solved
    Another macro has made a mistake & it is working perfect
    Thnx Alot Sir

  4. #24
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0

    Macro Correction(If condition met then do something & if not then do nothing)



    “Moderator” Notice
    September 2020
    Given up with this “OP” , Avinash around September 2020. https://excelfox.com/forum/showthrea...ll=1#post14972
    https://excelfox.com/forum/showthrea...ll=1#post14972

    I am no longer monitoring what its doings. It had curiosity appeal for a while, but even that has worn off me now!
    It’s getting worse by the Day. Its still doing whatever it is that it is doing and getting Replies and answers at excelforum.com and likely a few places I don’t know about.








    Hi Experts,

    Code:
    Option Explicit
    
    Sub STEP2()
    Dim wkb As Workbook
    Set wkb = Workbooks.Add
    wkb.SaveAs Filename:="C:\Users\WolfieeeStyle\Desktop\FALSEFALSEFALSE.xlsx"
    wkb.Close
    Dim fso As Object
    Dim strFileName As String
    Dim strFileExists As String
    Set fso = CreateObject("scripting.filesystemobject")
     
        strFileName = "C:\Users\WolfieeeStyle\Desktop\FALSEFALSEFALSE.xlsx"
        strFileExists = Dir(strFileName)
     
       If strFileExists > "" Then
       fso.movefile Source:="C:\Users\WolfieeeStyle\Desktop\FALSEFALSEFALSE.xlsx", _
                    Destination:="C:\Users\WolfieeeStyle\Desktop\WolfieeeStyle\9.15\FALSEFALSEFALSE.xlsx"
         Shell "taskkill /F /IM EXCEL.EXE"
        Else
            
        End If
        
    End Sub
    This macro does what i want & I need a confirmation that this macro is perfect & it has no errors & if there is anything which needs to be modified then plz modify the same & let me know


    Thnx




    Cross Post

    https://eileenslounge.com/viewtopic....273280#p273280
    Last edited by DocAElstein; 09-26-2020 at 07:04 PM. Reason: cross post

  5. #25
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0

    move the file if condition met

    Hello Guys,

    If column M data of ap.xls matches with column A data of sample2.xlsx (sheet2) (May be Column M data will be blank or 0 so ignore that)& column G data of oo.xlsx matches with column A data of sample2.xlsx (sheet2) then move the file C:\Users\WolfieeeStyle\Desktop\sample5.xlsx to C:\Users\WolfieeeStyle\Desktop

    Macro will be placed in a seperate file macro.xlsm

    (Number will be positive or negatiove , No issue with the positive or negative , the number should be present is must)



    Thnx Alot
    Attached Files Attached Files

  6. #26
    Senior Member
    Join Date
    Jul 2019
    Posts
    382
    Rep Power
    0
    Problem Solved

  7. #27
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,439
    Rep Power
    10
    As almost always you forgot to tell us how/ where it was solved
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

Similar Threads

  1. Replies: 85
    Last Post: 06-09-2020, 05:58 PM
  2. Replies: 4
    Last Post: 05-08-2014, 10:12 PM
  3. Replies: 7
    Last Post: 08-28-2013, 12:57 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •