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>
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>