Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Sending active worksheet and renaming

I'd like to send the active worksheet via outlook and rename the sent
worksheet to whatever the value is in cell B4. Can this be done?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Sending active worksheet and renaming

Yes you can, try this

Sub Mail_ActiveSheet_Outlook()
Dim OutApp As Object
Dim OutMail As Object
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.Sheets(1).Name = .Sheets(1).Range("B4").Value
.SaveAs "Part of " & ThisWorkbook.Name _
& " " & strdate & ".xls"

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add wb.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Qaspec" wrote in message ...
I'd like to send the active worksheet via outlook and rename the sent
worksheet to whatever the value is in cell B4. Can this be done?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Sending active worksheet and renaming

How about also naming the new workbook with the value of cell b4 on the sent
worksheet?

"Ron de Bruin" wrote:

Yes you can, try this

Sub Mail_ActiveSheet_Outlook()
Dim OutApp As Object
Dim OutMail As Object
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.Sheets(1).Name = .Sheets(1).Range("B4").Value
.SaveAs "Part of " & ThisWorkbook.Name _
& " " & strdate & ".xls"

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add wb.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Qaspec" wrote in message ...
I'd like to send the active worksheet via outlook and rename the sent
worksheet to whatever the value is in cell B4. Can this be done?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Sending active worksheet and renaming

Try this then

.Sheets(1).Name = .Sheets(1).Range("B4").Value
.SaveAs .Sheets(1).Range("B4").Value _
& " " & strdate & ".xls"



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Qaspec" wrote in message ...
How about also naming the new workbook with the value of cell b4 on the sent
worksheet?

"Ron de Bruin" wrote:

Yes you can, try this

Sub Mail_ActiveSheet_Outlook()
Dim OutApp As Object
Dim OutMail As Object
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.Sheets(1).Name = .Sheets(1).Range("B4").Value
.SaveAs "Part of " & ThisWorkbook.Name _
& " " & strdate & ".xls"

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add wb.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Qaspec" wrote in message ...
I'd like to send the active worksheet via outlook and rename the sent
worksheet to whatever the value is in cell B4. Can this be done?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet renaming jwilliam33 Excel Discussion (Misc queries) 5 December 6th 08 09:14 PM
sending the active worksheet and an additional new sheet Qaspec Excel Programming 1 February 2nd 05 02:57 AM
Renaming the Worksheet through VBA abxy[_24_] Excel Programming 4 February 9th 04 07:32 PM
renaming the active sheet tjtjjtjt[_2_] Excel Programming 1 January 27th 04 04:00 PM
Help sending active sheet to email list Kingtriotn Excel Programming 5 January 18th 04 10:43 AM


All times are GMT +1. The time now is 12:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"