VBA Kill .FullName not working

MDuff

Well-known Member
Joined
Dec 29, 2002
Messages
529
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have this code that emails a sheet and removes the file from the HDD But now for strange reason the file that was created will be removed from the HDD but there is still a copy of it open in excel. this is very strange to me as the only adjustment I made to the code was adding an other WB to the file that is created. any one have any ideas...
thanks in advance

<code>
Sub Mailme()
Dim MyArr
MyArr = Sheets("Master").Range("G1")
Dim wb As Workbook
Dim ws As Worksheet
Dim strdate As String
strdate = Format(Now, "dd-mm-yy")

Application.ScreenUpdating = False


Sheets(Array("MO-TS", "MO-DS", "MO-CG")).Copy
For Each ws In Worksheets
With ws.UsedRange
.Value = .Value
End With


Next
Set wb = ActiveWorkbook
With wb

.SaveAs "\\Crsjofil001\SupportAreas\Account Resource Management\WFM - US\RTA\Moto IDP\Save\Moto IDP" _
& " " & strdate & ".xls"
On Error Resume Next
.SendMail MyArr, Subject:="Moto IDP"

.ChangeFileAccess xlReadOnly
MsgBox "Email Sent"
On Error GoTo 0

Kill .FullName

End With
Application.ScreenUpdating = True

End Sub
</code>
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Use:

Workbooks("BOOK1.XLS").Close SaveChanges:=False

to close the workbook doing the code. Use:

Kill "TestFile"

to remove a file that is not the current file!
 
Upvote 0

Forum statistics

Threads
1,216,195
Messages
6,129,458
Members
449,510
Latest member
David Clark

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top