Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default send sheet as attachment

I want to send a active work sheet in excel as an attachment for only a
certain workbook (BookA). I created a macro button on the toolbar, using
the default happyface as the icon, and assigned the macro below to that
button. I saved that macro on that workbook (BookA). My problem is that no
matter what workbook I have open if I click the happy face icon and it will
run that macro. I do not want the macro to run on anywork book open only
that certain one (BookA). What code do I need to add where that macro only
runs when that workbook (BookA) is open and not workbook BookB, C, D,.....)
open?
I do not want people to have a different workbook open and inadverently
press that button. I thought abought doing a command button on each
worksheet but then I would want to strip the button and macro from the
worksheet that will be sent before it is sent so that the reciepment would
not have the command button and macro on the file that they get.

'Name of macro mailsheet
Sub mailsheet()
'Copies the active sheet to a new workbook
ActiveSheet.Copy
'Saves new workbook with new worksheet name from org. filename 'and adds the
text "Part of"
'to the front of worksheet the will be emailed.
ActiveWorkbook.SaveAs "Part of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
'Sends to the email to address below and with the "Tester" as the subject
line.
ActiveWorkbook.sendmail
'Changes the file that is emailed to read only in MY Documents.
ActiveWorkbook.ChangeFileAccess xlReadOnly
'Delets the temp file "part of" located in my documents.
Kill ActiveWorkbook.FullName
'Closes the file that was opened to send
ActiveWorkbook.Close True
End Sub


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
Help to Send as attachment. Pools New Users to Excel 7 July 2nd 06 03:03 AM
Send as Attachment [email protected] Excel Discussion (Misc queries) 0 June 7th 06 06:50 PM
My send to in excel/word does not offer send as attachment Mstink Excel Discussion (Misc queries) 11 March 16th 06 02:49 PM
send sheet to email as html attachment Pieter Excel Programming 10 October 24th 05 09:50 PM
send as attachment confused in NC Excel Discussion (Misc queries) 1 July 19th 05 06:02 PM


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