Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Help on e-mailing worksheets

Hi, I have adapted some code posted on here in order to e-mail each
sheet in a workbook to the e-mail addresses entered into cell A1 on
each sheet. What I would like to do is to break all the links in the
new workbooks before they are sent. I would also like to insert a
message box asking to confirm the action before it is carried out (ie -
"e-mail separate sheets?" Yes/No/Cancel)
Any help would be very much appreciated - Thanks!
The existing code I have is as follows:
Sub email_worksheets2()
Dim sh As Worksheet
Dim wb As Workbook
Application.ScreenUpdating = False
For Each sh In ThisWorkbook.Worksheets
If sh.Range("a1").Value Like "?*@?*.?*" Then
sh.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "Cost Centre Reporting - " & sh.Name & ".xls"
.SendMail ActiveSheet.Range("a1").Value, _
"Please find attached your detailed " & sh.Name & "
cost centre report"
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
End If
Next sh
Application.ScreenUpdating = True
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Help on e-mailing worksheets

Hi ell7

message box asking to confirm the action before it is carried out

For every sheet ? or only when you start the macro

What I would like to do is to break all the links

Formula links ?

I change the macro for you when you answer the questions



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



"ell7" wrote in message oups.com...
Hi, I have adapted some code posted on here in order to e-mail each
sheet in a workbook to the e-mail addresses entered into cell A1 on
each sheet. What I would like to do is to break all the links in the
new workbooks before they are sent. I would also like to insert a
message box asking to confirm the action before it is carried out (ie -
"e-mail separate sheets?" Yes/No/Cancel)
Any help would be very much appreciated - Thanks!
The existing code I have is as follows:
Sub email_worksheets2()
Dim sh As Worksheet
Dim wb As Workbook
Application.ScreenUpdating = False
For Each sh In ThisWorkbook.Worksheets
If sh.Range("a1").Value Like "?*@?*.?*" Then
sh.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "Cost Centre Reporting - " & sh.Name & ".xls"
.SendMail ActiveSheet.Range("a1").Value, _
"Please find attached your detailed " & sh.Name & "
cost centre report"
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
End If
Next sh
Application.ScreenUpdating = True
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Help on e-mailing worksheets

Hi Ron - thanks for your quick reply. I only need one message box for
when I start the macro. And, yes, I want to break the formula links to
external references. I have a lot of references to files that the
recipients of the worksheets do not have access to, so I would like to
break these links. I would prefer to do this rather than simply to
convert the formulae to values as I would like to retain the internal
formulae within the sheet itself.
Thanks in advance for your help.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Help on e-mailing worksheets

Hi ell7

Test this one for me and post back if this is what you want

Sub Email_worksheets_Break_links_Test()
Dim sh As Worksheet
Dim wb As Workbook
Dim WorkbookLinks As Variant
Dim i As Long
Dim Answer

Answer = MsgBox("Do you want to mail all sheets that have a mail address in A1 ?", _
vbYesNo, "Ron's code test!")

If Answer = vbYes Then

Application.ScreenUpdating = False
For Each sh In ThisWorkbook.Worksheets
If sh.Range("a1").Value Like "?*@?*.?*" Then
sh.Copy
Set wb = ActiveWorkbook

WorkbookLinks = wb.LinkSources(Type:=xlLinkTypeExcelLinks)
If Not IsEmpty(WorkbookLinks) Then
For i = 1 To UBound(WorkbookLinks)
wb.BreakLink _
Name:=WorkbookLinks(i), _
Type:=xlLinkTypeExcelLinks
Next i
Else
' No Links to other workbooks"
End If

With wb
.SaveAs "Cost Centre Reporting - " & sh.Name & ".xls"
.SendMail wb.Sheets(1).Range("a1").Value, _
"Please find attached your detailed " & sh.Name & " cost centre report"
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
End If
Next sh
Application.ScreenUpdating = True

Else
MsgBox "You not want to run the macro"
End If

End Sub


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



"ell7" wrote in message ups.com...
Hi Ron - thanks for your quick reply. I only need one message box for
when I start the macro. And, yes, I want to break the formula links to
external references. I have a lot of references to files that the
recipients of the worksheets do not have access to, so I would like to
break these links. I would prefer to do this rather than simply to
convert the formulae to values as I would like to retain the internal
formulae within the sheet itself.
Thanks in advance for your help.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Help on e-mailing worksheets

Absolutely fantastic - it works like a dream!! Thank you so much.

One more question - is there any way to enter text into the actual body
of the e-mail, rather than just the subject box? Say for example
"please find attached your detailed cost centre analysis...."



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Help on e-mailing worksheets


Hi ell7

Absolutely fantastic - it works like a dream!! Thank you so much.

Great

One more question - is there any way to enter text into the actual body
of the e-mail, rather than just the subject box? Say for example
"please find attached your detailed cost centre analysis...."


Not with SendMail but if you use Outlook you can use code that use the Outlook object model.
See this page for a example
http://www.rondebruin.nl/mail/folder2/mail5.htm



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



"ell7" wrote in message ups.com...
Absolutely fantastic - it works like a dream!! Thank you so much.

One more question - is there any way to enter text into the actual body
of the e-mail, rather than just the subject box? Say for example
"please find attached your detailed cost centre analysis...."



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Help on e-mailing worksheets

Thanks Ron - you've been a great help

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
I need to import my Excel Mailing list into mailing label format. Gord Dibben Excel Discussion (Misc queries) 0 November 5th 09 10:16 PM
I need to import my Excel Mailing list into mailing label format. Lyn Excel Discussion (Misc queries) 0 November 5th 09 08:11 PM
merging and mailing multiple worksheets April Excel Discussion (Misc queries) 1 February 22nd 09 09:41 PM
E-mailing single worksheets LeeGBristol Excel Discussion (Misc queries) 1 November 16th 06 04:05 PM
how do i convert MS Word mailing labels into an Excel mailing lis. unrhyll Excel Discussion (Misc queries) 1 February 4th 05 12:19 AM


All times are GMT +1. The time now is 04:27 AM.

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

About Us

"It's about Microsoft Excel"