Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10
Default Need help with Email Code (PLEASE)

I am trying to code a button to create an email with the active
sheet as an attachment. Due to some restrictions with the other code
in the workbook, here is what I am wanting it to do.

- Copy Currently active sheet to a NEW work book (Including Sheet
protection cell values, formatiing , vba code (Include code under
“this workbook”, etc)
- Rename the new workbook to the Active sheet name that was copied
over.
- Attach the Workbook to a new out look email. (Without saving
workbook to a file.)
- Close the new workbook with out saving.

Here is the code I have so far, but am stuck as to how to copy active
sheet and rename it.

Sub Button1_Click()
Dim OL As Object ' Outlook Object
Dim EmailItem As Object ' A new mail item (e-mail)
Dim lngLoop As Long
Dim FileName As String ' The name of the file we are attaching
Dim SheetName As String ' Email Subject

Set OL = CreateObject("Outlook.Application") ' New Outlook
application
Set EmailItem = OL.CreateItem(OLMailItem) ' New MailItem

' Shut Down Screen and Events
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False

SheetName = ActiveSheet.Name ' Email Subject

'Need Code here to create the new workbook with an
‘exact copy of the active worksheet in it. (Including
‘Sheet protection cell values, formatiing , vba code
‘ (Include code under “this workbook”, etc)
'
' I then need to rename the workbook to the sheet
‘ name copied. (SheetName)

' Load Email
With EmailItem ' with the newly created e-mail
.Subject = SheetName
.Body = SheetName
.Attachments.Add SheetName 'Add New Workbook
.Display ' Load The Email
End With

Set OL = Nothing ' clean down memory
Set EmailItem = Nothing ' clean down memory

‘ Code here to close the New workbook (no Save)

Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,123
Default Need help with Email Code (PLEASE)

Please not post in more then one group
See your other thread

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



wrote in message ...
I am trying to code a button to create an email with the active
sheet as an attachment. Due to some restrictions with the other code
in the workbook, here is what I am wanting it to do.

- Copy Currently active sheet to a NEW work book (Including Sheet
protection cell values, formatiing , vba code (Include code under
"this workbook", etc)
- Rename the new workbook to the Active sheet name that was copied
over.
- Attach the Workbook to a new out look email. (Without saving
workbook to a file.)
- Close the new workbook with out saving.

Here is the code I have so far, but am stuck as to how to copy active
sheet and rename it.

Sub Button1_Click()
Dim OL As Object ' Outlook Object
Dim EmailItem As Object ' A new mail item (e-mail)
Dim lngLoop As Long
Dim FileName As String ' The name of the file we are attaching
Dim SheetName As String ' Email Subject

Set OL = CreateObject("Outlook.Application") ' New Outlook
application
Set EmailItem = OL.CreateItem(OLMailItem) ' New MailItem

' Shut Down Screen and Events
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False

SheetName = ActiveSheet.Name ' Email Subject

'Need Code here to create the new workbook with an
'exact copy of the active worksheet in it. (Including
'Sheet protection cell values, formatiing , vba code
' (Include code under "this workbook", etc)
'
' I then need to rename the workbook to the sheet
' name copied. (SheetName)

' Load Email
With EmailItem ' with the newly created e-mail
.Subject = SheetName
.Body = SheetName
.Attachments.Add SheetName 'Add New Workbook
.Display ' Load The Email
End With

Set OL = Nothing ' clean down memory
Set EmailItem = Nothing ' clean down memory

' Code here to close the New workbook (no Save)

Application.ScreenUpdating = True
Application.EnableEvents = True
Application.DisplayAlerts = True
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10
Default Need help with Email Code (PLEASE)


As much as I appreciate the help, the other post did not get me where
I was hoping to go. I posted in two groups to get diffrent opinions,
and many may not read both groups.

On Sat, 21 Oct 2006 00:01:03 +0200, "Ron de Bruin"
wrote:

Please not post in more then one group
See your other thread

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,123
Default Need help with Email Code (PLEASE)

See
http://www.cpearson.com/excel/newposte.htm

And answer in your other thread

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



wrote in message ...

As much as I appreciate the help, the other post did not get me where
I was hoping to go. I posted in two groups to get diffrent opinions,
and many may not read both groups.

On Sat, 21 Oct 2006 00:01:03 +0200, "Ron de Bruin"
wrote:

Please not post in more then one group
See your other thread



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 618
Default Need help with Email Code (PLEASE)

In which case, please learn the difference between multiposting &
crossposting.
http://www.cs.tut.fi/~jkorpela/usenet/xpost.html
--
David Biddulph

wrote in message
...

As much as I appreciate the help, the other post did not get me where
I was hoping to go. I posted in two groups to get diffrent opinions,
and many may not read both groups.


On Sat, 21 Oct 2006 00:01:03 +0200, "Ron de Bruin"
wrote:

Please not post in more then one group
See your other thread



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
Code to prevent Remove Split or Unfreeze Panes? dk_ Excel Discussion (Misc queries) 6 October 9th 06 08:35 PM
Text formatting Kace Excel Worksheet Functions 1 September 18th 06 08:28 PM
Email a single worksheet Sandy Excel Discussion (Misc queries) 8 April 28th 06 02:37 AM
Email editor closes when forwarding Excel-embedded email Bambina Setting up and Configuration of Excel 0 March 16th 06 10:45 PM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 3rd 05 03:40 PM


All times are GMT +1. The time now is 01:37 PM.

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"