Close.xls file by a macro

User avatar
HansV
Administrator
Posts: 78457
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Close.xls file by a macro

Post by HansV »

You should replace "WINDOWTITLE eq Microsoft Excel - Book3.xls" with the title displayed in the title bar of the Excel window of the workbook. Here is an example:

S3445.png

For that workbook, you'd use "Allocate.xlsm - Excel"
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

zyxw1234
Banned
Posts: 253
Joined: 22 Apr 2020, 17:24

Re: Close.xls file by a macro

Post by zyxw1234 »

But it is not working for that file
No Problem Sir
Thnx Alot For the Great Help HansV Sir

kjfhg
Banned
Posts: 1
Joined: 16 Aug 2020, 09:27

Re: Close.xls file by a macro

Post by kjfhg »

I got the solution for this Problem

Code: Select all

Option Explicit

Sub STEP2()
Dim wkb As Workbook
Set wkb = Workbooks.Add
wkb.SaveAs Filename:="C:\Users\**I've been banned**\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\**I've been banned**\Desktop\FALSEFALSEFALSE.xlsx"
    strFileExists = Dir(strFileName)
 
   If strFileExists > "" Then
   fso.movefile Source:="C:\Users\**I've been banned**\Desktop\FALSEFALSEFALSE.xlsx", _
                Destination:="C:\Users\**I've been banned**\Desktop\**I've been banned**\9.15\FALSEFALSEFALSE.xlsx"
     Shell "taskkill /F /IM EXCEL.EXE"
    Else
        
    End If
    
End Sub
Is there any modification required then plz let me know?
This is my logic & this macro doest the same what i want & this will be the perfect sultion for me as per my needs