A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Delete Excel Command Button Before Email is Sent



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 27th 06, 06:51 PM posted to microsoft.public.outlook.program_vba
White Horse
external usenet poster
 
Posts: 4
Default Delete Excel Command Button Before Email is Sent

On an Excel (2003) sheet, I have a command button that executes the
following code to send an email (Outlook 2003) with the Excel workbook
attached:

================================================== =========
Private Sub CommandButton1_Click()
SendMail
End Sub
================================================== =========

Public Sub SendMail()
Dim ol As Object, myItem As Object
Dim myAtts As Outlook.Attachments

ActiveSheet.Shapes("CommandButton1").Delete

Set ol = CreateObject("outlook.application")
Set myItem = ol.CreateItem(olMailItem)
myItem.To = "Lu"
myItem.Subject = "Approval Request"
myItem.Body = "Today's numbers are attached."

Set myAtts = myItem.Attachments
myAtts.Add ActiveWorkbook.FullName

myItem.display

Set ol = Nothing
Set myItem = Nothing
Application.DisplayAlerts = False
ActiveWorkbook.Close
End Sub
================================================== =========

The command - ActiveSheet.Shapes("CommandButton1").Delete - works. The
button disappears if you set a "stop" at the next line.

However, the Excel file that is actually sent has the button still
displayed.

How can I delete the button from the Excel attachment - it will not
work for the receipient so I want it deleted.

This file is used twice a week, so I don't want to delete the button
and then save the file before sending.

Thanks,
Mike

Ads
  #2  
Old April 28th 06, 07:01 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Delete Excel Command Button Before Email is Sent

Am 27 Apr 2006 09:51:31 -0700 schrieb White Horse:

Because you attach the saved file, no not saved changes could be considered.
Maybe it works if you use the Worksheet.MailEnvelope function?

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


On an Excel (2003) sheet, I have a command button that executes the
following code to send an email (Outlook 2003) with the Excel workbook
attached:

================================================== =========
Private Sub CommandButton1_Click()
SendMail
End Sub
================================================== =========

Public Sub SendMail()
Dim ol As Object, myItem As Object
Dim myAtts As Outlook.Attachments

ActiveSheet.Shapes("CommandButton1").Delete

Set ol = CreateObject("outlook.application")
Set myItem = ol.CreateItem(olMailItem)
myItem.To = "Lu"
myItem.Subject = "Approval Request"
myItem.Body = "Today's numbers are attached."

Set myAtts = myItem.Attachments
myAtts.Add ActiveWorkbook.FullName

myItem.display

Set ol = Nothing
Set myItem = Nothing
Application.DisplayAlerts = False
ActiveWorkbook.Close
End Sub
================================================== =========

The command - ActiveSheet.Shapes("CommandButton1").Delete - works. The
button disappears if you set a "stop" at the next line.

However, the Excel file that is actually sent has the button still
displayed.

How can I delete the button from the Excel attachment - it will not
work for the receipient so I want it deleted.

This file is used twice a week, so I don't want to delete the button
and then save the file before sending.

Thanks,
Mike

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I modify Delete button to also mark item as read? [email protected] Outlook and VBA 1 April 24th 06 07:14 AM
O2003- how to show email account info? (esp. via email hyperlink on a button) StargateFan Outlook - General Queries 2 March 22nd 06 01:35 PM
Email editor closes when forwarding Excel-embedded email Outlook - General Queries 0 March 18th 06 03:01 PM
Command bar button FaceID Icon donald Add-ins for Outlook 20 February 9th 06 07:42 PM
Command button not working on read page jbtempe Outlook - Using Forms 2 January 14th 06 12:25 AM


All times are GMT +1. The time now is 12:54 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.