ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Email challenge (https://www.excelbanter.com/excel-programming/340563-email-challenge.html)

Steved

Email challenge
 
Hello from Steved

I would like to email A worksheet called To Depots and Value the cells in
that workbook

I'm Getting a complie error

method or data member not found

This is where itbis highlighting .Name_

Please help Thankyou.

Sub Mail_Todepot()
Dim wb As Workbook
Dim strdate As String

strdate = Format(Now, "dd-mm-yy")

Application.ScreenUpdating = False

Sheets("To Depot").Copy
ActiveSheet.Copy
Cells.Copy
Cells.PasteSpecial xlPasteValues
Cells(1).Select
Worksheets(1).Select
Application.CutCopyMode = False

With wb
.SaveAs "Part of" & ThisWorkbook.Name_

& " "& strdate &"C:/To Depots/Kilometres.xls"

.SendMail ",_
"Kilometres Per Bus"

.ChangeFileAccessxlReadOnly
Kill.FullName

.Close False
End With

Application.ScreenUpdating = True
End Sub



Norman Jones

Email challenge
 
Hi Steve,

With wb


wb has not been set to any workbook.

Try replacing this line with:

Set wb = ActiveWorkbook
With wb

---
Regards,
Norman



"Steved" wrote in message
...
Hello from Steved

I would like to email A worksheet called To Depots and Value the cells in
that workbook

I'm Getting a complie error

method or data member not found

This is where itbis highlighting .Name_

Please help Thankyou.

Sub Mail_Todepot()
Dim wb As Workbook
Dim strdate As String

strdate = Format(Now, "dd-mm-yy")

Application.ScreenUpdating = False

Sheets("To Depot").Copy
ActiveSheet.Copy
Cells.Copy
Cells.PasteSpecial xlPasteValues
Cells(1).Select
Worksheets(1).Select
Application.CutCopyMode = False

With wb
.SaveAs "Part of" & ThisWorkbook.Name_

& " "& strdate &"C:/To Depots/Kilometres.xls"

.SendMail ",_
"Kilometres Per Bus"

.ChangeFileAccessxlReadOnly
Kill.FullName

.Close False
End With

Application.ScreenUpdating = True
End Sub





Steved

Email challenge
 
Thanks Norman

"Norman Jones" wrote:

Hi Steve,

With wb


wb has not been set to any workbook.

Try replacing this line with:

Set wb = ActiveWorkbook
With wb

---
Regards,
Norman



"Steved" wrote in message
...
Hello from Steved

I would like to email A worksheet called To Depots and Value the cells in
that workbook

I'm Getting a complie error

method or data member not found

This is where itbis highlighting .Name_

Please help Thankyou.

Sub Mail_Todepot()
Dim wb As Workbook
Dim strdate As String

strdate = Format(Now, "dd-mm-yy")

Application.ScreenUpdating = False

Sheets("To Depot").Copy
ActiveSheet.Copy
Cells.Copy
Cells.PasteSpecial xlPasteValues
Cells(1).Select
Worksheets(1).Select
Application.CutCopyMode = False

With wb
.SaveAs "Part of" & ThisWorkbook.Name_

& " "& strdate &"C:/To Depots/Kilometres.xls"

.SendMail ",_
"Kilometres Per Bus"

.ChangeFileAccessxlReadOnly
Kill.FullName

.Close False
End With

Application.ScreenUpdating = True
End Sub







All times are GMT +1. The time now is 02:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com