LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Export only current sheet to email?

Hi,

I'd like a way that I can place a form button on a worksheet in Excel, that
when pressed, just exports the current sheet to a new Excel file, (preferably
with a message prompt to give it a file name - .xls added automatically),
saves it to the desktop, and then automatically attaches it to a new email in
Outlook. (Similar to Send to mail recipient as attachment, except only with
that sheet in the work book.)

Does anyone know if this is possible with macros? I would expect many people
would find it useful.

Any replies are appreciated!

Here's some code I found in the community that might be able to be modified.
(It's supposed to export the sheet into a different existing file.)

section 'Change Here'):
Sub Macro2()

Dim wshO As Worksheet, nameO As String 'Origin sheet
Dim wshD As Worksheet, WbkD As Workbook, nameD As String 'Destination
variables
Dim count As Long


' Set variables
'------ CHANGE HERE ------------
Set wshO = ActiveSheet
Set WbkD = Workbooks(2)
'-------------------------------
nameO = wshO.Name
count = WbkD.Sheets.count

'Get name from user
nameD = Application.InputBox("Enter new name", "New Sheet Name")
If nameD = "False" Then Exit Sub 'Cancelled by user

'Copy sheet
wshO.Copy After:=Workbooks(2).Sheets(count)
Set wshD = WbkD.Sheets(count + 1) 'new sheet is last one

'Rename
On Error Resume Next
wshD.Name = nameD
If Err < 0 Then
MsgBox "The provided name '" & nameD & "' is not valie (invalid or
already exist)" & _
vbNewLine & "Please, set it manually."
End If
End Sub

--
Regards,
Sébastien



Special Thanks in advance!

Ben
 
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
how do i export data to an email with excel A Rutherford[_2_] Excel Discussion (Misc queries) 1 May 19th 09 08:26 PM
How do I export data from a workbook to an email A Rutherford Excel Discussion (Misc queries) 1 May 19th 09 07:22 PM
Email current page Mike Excel Discussion (Misc queries) 4 October 5th 08 05:49 PM
macro - email current page Mack Neff[_2_] Excel Programming 0 June 6th 07 02:17 AM
Lotus Notes/Export to email na Excel Programming 1 November 16th 04 09:14 PM


All times are GMT +1. The time now is 10:06 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"