synapse play so hard 60939 Posts user info edit post |
Say I have an Excel 2003 Workbook full of 40 sheets. And I want to sent each sheet to a different email address. I want each recipient to receive a workbook with just their sheet included, not their worksheet converted to html and sent as the message body (which is all I can figure out how to do).
Anyone know how to do this? 7/18/2006 2:19:04 PM |
El Nachó special helper 16370 Posts user info edit post |
well the hard way would be to copy and paste each sheet into it's own document.
There's probably an easier way, but I don't use excel enough to know it. 7/18/2006 2:20:49 PM |
seedless All American 27142 Posts user info edit post |
^ lol, why even bother to post that 7/18/2006 2:22:58 PM |
El Nachó special helper 16370 Posts user info edit post |
because I'm almost as dumb as you. 7/18/2006 2:24:55 PM |
synapse play so hard 60939 Posts user info edit post |
^^^ thats what I'm trying to avoid by this post.
I did find this http://www.dicks-clicks.com/excel/olSending.htm#Sending_One_Sheet_as_an_Attachment
but I was hoping to avoid since it involved code (though maybe this would be a good time to start playing with VBA ). Does this code even look like it would work? It was written for Excel 2000...will it work in 2003 too?
Are there any non-code solutions? 7/18/2006 2:29:40 PM |
The Coz Tempus Fugitive 26099 Posts user info edit post |
By the time you find the answer, you could have already finished the brute force method. Good to know for the future, I suppose. 7/18/2006 3:54:07 PM |
darkone (\/) (;,,,;) (\/) 11610 Posts user info edit post |
There's proabably a method involving turning the workbook into a database and using Access to do what you want. I have no details, it's just an idea. 7/18/2006 4:31:36 PM |
agentlion All American 13936 Posts user info edit post |
^^^
there's probably no way to do this without code. but don't be scared of VBA - it's your friend.
And i'm your friend too for modifying the code found in that post to work for your needs:
Sub SendAllSheets()
' initialize Outlook and mail objects On Error Resume Next Set olApp = GetObject(, "Outlook.Application") If Err.Number = 429 Then Set olApp = CreateObject("Outlook.application") End If On Error GoTo 0 Dim recipientsArray() As String Dim recipientsRange As Range ' store the email Set recipientsRange = Range("addresslist") ' named range in Worksheet1 ReDim recipientsArray(1 To recipientsRange.Rows.Count) ' set array to length of list, starting with index = 1 Dim counter As Integer counter = 1 For Each oneName In recipientsRange ' SHOULD be able to do something like recipientsArray = Array(recipientsRange) recipientsArray(counter) = oneName ' recipientsArray = recipientsRange.... or something? counter = counter + 1 Next oneName counter = 2 ' the worksheets to send start with worksheet #2 For Each Recipient In recipientsArray ' loop through each recipient in array ThisWorkbook.Sheets(counter).Copy ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & "sheet.xls" Dim olMail As Object ' MailItem Set olMail = olApp.CreateItem(olMailItem) With olMail .Recipients.Add Recipient .Subject = "One worksheet" ' could put different subjects in a named range too, if you want customization .Body = "Here is the worksheet " & vbCrLf ' same with body - can be customized .Attachments.Add ActiveWorkbook.FullName .Display .Send ' may cause an alert that creates a 5 second delay! Might be better to remove .Send and hit Send manually in Outlook End With ActiveWorkbook.Close False Kill ThisWorkbook.Path & "\" & "sheet.xls" Set olMail = Nothing counter = counter + 1 Next Recipient Set olApp = Nothing
End Sub
How to use: 1) In your workbook with all the sheets, insert a new sheet at the very beginning (i.e. it has to be the first worksheet of all 40 or however many you have). It doesn't matter what the name is 2) in the new worksheet, make a list of all the email addresses you want, in a single column, in the same order as the worksheets that you want sent to the addresses 3) create a named range called "addresslist" with that list. to do so, highlight the list, then go to Insert > Name > Define, type addresslist as the name, click Add, then OK. 4) Open the VBA editor (Tools > Macro > Visual Basic Editor, or just Alt+F11) 5) in the VBA editor, you'll see the the workbook structure down the left side, with the names of all the worksheets. Go to the last one and it should be "ThisWorkbook". Double click that one, then paste all the above code into the right pane, and Save. (you could really put it into any of the worksheets, but it makes more sense in the ThisWorkbook object 6) Close the VBA editor if you want 7) Go to Tools > Macro > Macros (or Alt+F8). Select "ThisWorkbook.SendAllSheets" and hit run.
Depending on your versions of Excel and outlook, some different things may happen. In the background, the code will pull the email addresses out of the list, create a new temporary workbook with each worksheet, add the new workbook to a new email message to each address, send the message, then delete the temporary sheet and do the next. In Outlook 2003, when the .Send command is called, Outlook forces you to wait about 5 seconds, then click Yes to send the message. If you remove the .Send line, it will create a whole lot of email messages, but won't send them. You'll have to go through and just click Send on all of them.
This code is error-prone and pretty rigid (for example, the list of recipients has to be the same length as the list of worksheets). It can be modified easily though to create more customization, like customized email subjects and bodies, multiple or different worksheets to certain addresses, multiple recipients for each worksheet, etc.7/18/2006 4:52:23 PM |
Perlith All American 7620 Posts user info edit post |
Quote : | "By the time you find the answer, you could have already finished the brute force method. Good to know for the future, I suppose." |
If this is a one-time or infrequent thing, I'm going to have to agree. If it's not, you should probably dabble in VBA (or VB.NET if available) to do it.
Outlook 2003 uses a different object model than does Outlook 2000. I haven't messed around with VBA, but I know VB.NET required me to add some references + some other stuff to create/send emails.7/18/2006 5:49:46 PM |
synapse play so hard 60939 Posts user info edit post |
Quote : | "By the time you find the answer, you could have already finished the brute force method. Good to know for the future, I suppose." |
thats the idea. I have to send out groups of worksheets pretty often.
^^ thanks for the code, I'll begin playing7/18/2006 6:04:58 PM |