Excel Macro For Attaching Multiple Files To One Email

Jan 15, 2014

I am currently attempting to use an excel macro to allow me to send a list of files to one person. I have managed to create a dynamic list where one sheet of the workbook has the list of files and checkboxes, and as certain ones are selected they appear in a list on the 'front sheet' of my workbook, which has the button to send the email.

My front sheet is set up in a way that in cell B3 I have the desired email address, B4 contains the subject and from B5 to B30 I have the list of selected attachments (although the length of the list obviously varies depending on the amount of files selected, when all are selected the list extends to B30).

I have the below vba code that allows me to create an email with the address and subject and attaches the file address from cell B5, but I would like to attach all the files in the list and am struggling to change the code to do so.

Code:
Sub CreateMail()

Dim objOutlook As Object
Dim objMail As Object
Dim rngTo As Range
Dim rngSubject As Range
Dim rngAttach As Range

Set objOutlook = CreateObject("Outlook.Application")

[Code] ........

I can add more by creating new ranges (rngAttach1, rngAttach2, rngAttach3 etc) and setting these to their respective locations but if, for example, only two files are selected, the list only covers cells B5 and B6, so when the macro looks up the file directory in B7 (rngAttach3) it returns an error because obviously there is nothing for it to find.

I have attempted to compile a loop and change the code to the version shown below but am having no luck.

Code:
Sub CreateMail()

Dim objOutlook As Object
Dim objMail As Object
Dim rngTo As Range
Dim rngSubject As Variant
Dim rngAttach As String
Dim iLoop As Long

[Code] ....

View 4 Replies


ADVERTISEMENT

Text Files Not Attaching To Email Correctly

Mar 31, 2014

I'm trying to send a few emails with some .txt files attached. It is sending the emails, along with text files, but the data within the text files are either missing or giving me weird Chinese symbols.

Here is the code:

[Code] .....

As I said, the email is sending no problem, with files attached, but the data within the files are corrupted. I've checked, and the links are referencing the correct files.

View 6 Replies View Related

Excel 2007 :: Save Files XLS In Macro Workbook And Send Email

Sep 3, 2012

I am using 2007. This may be something simple but I can't seem to find a solution to this, I have an excel macro enabled workbook which produces a daily report the final task is to save and send an email but I need the file to save as an xls rather than xlsx as some of the recipients are unable to open the file here is the code used for the tasks in the

workbook:Sub Step1_Refresh()
'
' Step1_Refresh Macro
'
'
ActiveWorkbook.RefreshAll
End Sub
Sub step2_save_close()

[Code] ........

View 1 Replies View Related

Excel 2007 :: Save Files XLS In Macro Workbook And Send Email?

Sep 3, 2012

I am using 2007, I have an excel macro enabled workbook which produces a daily report the final task is to save and send an email but I need the file to save as an xls rather than xlsx as some of the recipients are unable to open the file.

Here is the code used for the tasks in the:

workbook:Sub Step1_Refresh()
'
' Step1_Refresh Macro
'
'

[Code]....

View 7 Replies View Related

Export To PDF Not Attaching To Email?

Jan 29, 2014

Code is supposed to export a selection of the worbook to a pdf in the workbook folder, and attach the file to an email, generating to/cc/subject/email dialogue. which it does.

it is also supposed to attach the file to the email, which is doesn't.

View 14 Replies View Related

Attaching Already Embedded PDF To Email?

Jan 14, 2014

My "Drawing" is embedded on Sheet1, later on in Sheet12 I click a button that'll send an automatic email to a user. I want to attach the embedded PDF onto this email if it is at all possible??

Code:
Dim Drawing As Object
After I've declared my variables I've tried setting the variable "Drawing" to the object, this is where I'm encountering my errors mainly "Type Mismatch" or Object Variable not set...

Code:
Sheets("Menu").Visible = True
Drawing = Sheet1.Shapes.range(Array("Drawing"))
Selection.Verb Verb:=xlPrimary
Sheets("Menu").Visible = False
At the bottom of the code, this is where i pull in the object

Code:
.To = Sheet12.range("L8")
.CC = ""
.BCC = ""
.Subject = "Arrange P&D Request"
.htmlbody = strbody & vbNewLine & Signature
.Attachments.Add ("Drawing")

View 9 Replies View Related

Attaching Signature To Email In Lotus Notes

Jul 17, 2013

Any ways to automatically send emails using Lotus Notes.

On Lotus Notes, I automatically have my signature to append to an email, however when I am running Johns script at the bottom it is replaced with the file path of my signature (i.e. C:Program Fileslotus
otesdatasig.htm), and when I comment out the part where strSignature is mentioned there is no signature.

My code is below:

Sub mySub()
Dim x As Integer
Dim UserName As String
Dim MailDbName As String
Dim Recipient As Variant
Dim Maildb As Object
Dim MailDoc As Object

[Code] ...........

View 1 Replies View Related

Attaching File To Lotus Notes Email

May 12, 2006

I managed to create the attached macro with help from stuff I've found in the internet. With this code, I am able to save the file and then send an email cia Lotus Notes. I need two things:

(1) The code to attach the file saved into the email that it sends

(2) The code so that the file is protected so that changes are not made by the recipient.

HERE IS THE
ActiveSheet.Copy
ActiveWorkbook.SaveAs filename:="V:TFMCO8 ReportingHistory" & [c22].Value & " " & Format$([c20], "- (YYYY-MM-DD)") & ".xls"
ActiveWorkbook.Close False

Dim Maildb As Object, UserName As String, MailDbName As String
Dim MailDoc As Object, Session As Object

Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, _
(Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GetDatabase("", MailDbName)
If Maildb.IsOpen Then
Else: Maildb.OpenMail...........

View 9 Replies View Related

Multiple CC Recipients In Excel Email Macro?

Jun 4, 2014

My Macro sends a PDF to a "To:" recipient and a "CC:" recipient. Both email addresses are referenced from cells. Here are the first four lines of the code:

With OutMail
.SentOnBehalfOfName = "myaddress@mycompanyname.com"
.to = Sheets("Sheet1").Range("N8").Value
.CC = Sheets("Sheet1").Range("T8").Value

The code works great right now. However.......

I've added another email address to Sheet1. The address is in U8. I need it to be the SECOND CC. I could BCC it easily, but that is not an option.

Code I would add behind .CC = Sheets("Sheet1").Range("T8").Value to make it also CC the email address in U8?

View 1 Replies View Related

Send Multiple Files Based On Criteria To Multiple Email Addresses?

Jun 29, 2014

I have a directory which contains many files, they are all names based on their locations. eg. Burwood-File1.xls,Burwood-File2.xls,Burwood-File3.xls etc

I have a master that which will contain the branch in the first column.

I have defined the directory location in a separate sheet as well as email template.

When I click on the Send Email button I want ti to attach the files that match the Branch name.

The Branch list will constantly grow.

View 2 Replies View Related

Excel 2010 :: Macro For Applying Changes To Multiple Files

Aug 16, 2012

Excel 2010, Windows 7

I have a whole ton of *.dbf files (98 to be exact), that are from ArcGIS shapefiles. These date1_date2.dbf files have point names, and values, as shown below.

NAMERASTERVALU
Point 1-9999.00000000
Point 2-9999.00000000
Point 3-9999.00000000
Point 4-4.93072701
Point 5-8.90071201

I'm trying to figure out how to transpose each of the dbf files and save them as a text file (tab deliminated). My original plan involved saving them all as text files, then using a convoluted Unix script (I'm what you call a "dirty programmer") to transpose them and then combine them all into a single file. Since there are so many files (and I plan to do this in the future as well), I thought if I could at least automate the text file creation, I'd be ahead of the game. Even better would be a macro that will transpose the data for EACH file, then create a 99 (98 files + header row) row, 5 column text file. Creating the text files (1 text file for each dbf file) automatically .

All the *.dbf files will have exactly the same # rows/columns (2 columns, 6 rows)

This is what I've tried so far.
1)open one of the dbf files in Excel
2)record my marco (using the Personal Macro Workbook option - so it will be available in any workbook)
2a) transpose data (and paste it right below the original data so that the new data is in rows 7 and 8 of the same file)
2b) save as text file (tab deliminated)
2c) stop recording, and end up with this:

NAMERASTERVALU
Point 1-9999.00000000
Point 2-9999.00000000
Point 3-9999.00000000
Point 4-4.93072701
Point 5-8.90071201
NAMEPoint 1Point 2Point 3Point 4Point 5
RASTERVALU-9999.00000000-9999.00000000-9999.00000000-4.93072701-8.90071201

So now I want to apply the macro I just created to all open workbooks (after I bring in all the bdf files), but the macro isn't listed when I click the "view macros" button. All I want to do is apply the steps I recorded in the macro to all open workbooks.

View 6 Replies View Related

Convert Multiple Text Files Into Excel Worksheets Macro

Apr 1, 2009

i have many file text which i want to open in an excel workbook in a way that each text file will be displayed in an excel sheet.

View 3 Replies View Related

Load Multiple Excel Files With Given Folder And Carry Out Same Macro On Them

Aug 16, 2013

i am working with a large data set of excel files . I need to format the sheets in a specified way . i have recorded a marco that does this . I now have the problem of creating an automatic loader that opens the files , carrys out my macro , then closes the files.

For example i have a folder X that has 10 files inside it. i would like to be able to load the first file , carry out the macro, close the file move it folder y . Then look back into Folder X , take the first file it see's , carry out the macro , close the file , move it folder y , the go back to folder x and carrying out this until all the files are done and stopping when the folder is empty

View 1 Replies View Related

Excel 2010 :: Macro On Multiple Files In A Folder Run Time Error 424

Jun 23, 2013

I have obtained a piece of code from online that runs a macro on multiple files in a single given a single folder. when i implement it though it throws a run time error 424 "object required' and point to 'Documents.Open FileName:=path & file' line of code. Is this because Dim file type is not declared?how do i fix this problem. also, im using excel 2010.A

VB:
Sub Mac()
Dim file
Dim path As String

[Code]....

View 4 Replies View Related

Excel 2010 :: Multiple CSV Files - Macro To Point Folder Where These Saved

May 11, 2012

I'm working on a project where I need to import 150 csv files into an Excel2010 workbook, with each csv file being on a seperate worksheet.

I would like to set up a macro to point to the folder I will have these saved in this up so that each month when I get updated csv files I can repeat the process and bring in the new data. how to create this, I'm very new to VBA?

View 1 Replies View Related

VBA - Attach Multiple Files To Email Using Folder Path Loop?

Feb 7, 2014

I have two pieces of code that each work, but I am struggling to combine the two.

I started with Ron de Bruin's code to attach multiple files to an email and then found more code that will loop through a folder to attach multiple files to an email.

Essentially, I would like the structure of Ron de Bruin's code, with the ability to have folder paths in the cell range, rather than file names.

Here is the code that works to loop through a folder, but it only works when I have the paths listed in one column, not in a range (e.g. columns C-Z)

Code:
Sub Send_Indv_Files()
Dim OutApp As Object
Dim OutMail As Object

[Code].....

View 4 Replies View Related

Excel 2003 :: Attaching Hyperlink To Command Button?

Dec 3, 2006

I am trying to attach a hyperlink to a command button in excel 2003. I open the control toolbox, select command button and place it on the worksheet. with the button selected and in design mode I click on the hyperlink button on the toolbar and allocate the hypelink address. Click on the button and it works fine untill I exit design mode then the button stops working.

View 8 Replies View Related

Copy Multiple Columns From Multiple Excel Files & Paste Into 1 Workbook

Nov 7, 2009

I have 8 different files all have a set of data in them

each one has a long list of (column a-n) however the number of rows change by date. I need each file copied into the finalfile.xls one after another. in the files that will be merged into the final file the final row i need copied is blank.
I have all the copy formulas and everything set, I just need a range to copy that automaticaly takes cell a10 to the first blank a cell from each file and pastes it in the finalfile.xls under the last paste so they dont over write each other.

View 9 Replies View Related

Macro To Send Email In Excel

Mar 20, 2014

Im looking to create a reporting mechanism for a shared worksheet that im putting together.

I am looking to create some that will automatically create an email (either through outlook, or using a userform) and automatically populate with my email address in the 'To' section and automatically populate the subject with 'Error/Info Change'. The user can then populate the main email body with whatever they want to notify me of.

Im then hoping that the code can be run through a macro which has been added to the quick access toolbar.

View 2 Replies View Related

Macro That Auto Generates Email Within Excel

May 26, 2010

I use a Macro that when run, will generate an email with the excel sheet attached. See attached example.

My two questions are:

- Is it possible for the body of the email that is generated to have spaces within the text? So it shows more like the below:

"Good morning,

Please find today's forecast for Friday, May 07, 2010 attached.

FRC Treasury Team"

- Also, the colors in the spreadsheet change automatically when the macro attaches the sheet. Why is this? Is it possible to do something so that this does not happen?

View 5 Replies View Related

Exporting To Multiple Excel Files

Feb 23, 2013

I have a spreadsheet with sales information contained in Sheet1. There are a number of columns including the Region column. I would like a bit of code that exports sales information to a number of Excel files dependent upon the region column. In other words the Region column can contain either North, East, South or West. I would like a different Excel file per region and I'd also like the file names to contain the name of the region + the month and year of the previous month ie if i was exporting today then the North Excel file would be called: "North Sales - Jan 2013".

View 9 Replies View Related

Multiple CSV Files Into One Excel Sheet

Oct 18, 2011

how to import multiple (selected from a certain folder) csv files (comma delimited) into one excel sheet.This has to be done with a VBA macro by the way.

View 1 Replies View Related

Excel Macro For Lotus Email With Attached File?

Aug 6, 2014

I'm trying to create an excel macro that can send emails with an attached file per row of my entry in excel I imagine it would be like the screenshot below. I've tried the code in the link below from a macro tutorial website but wasn't able to make it work due to error DataObject is unkown I'm using excel 2013 and lotus notes 8.5 as my email.

View 9 Replies View Related

Pulling Data From Multiple Excel Files?

Jun 3, 2013

I am trying to use the following formula to pull out data from multiple excel files in a folder called "Certificate".

='D:SSR Sec and Techcertificate[STUDENT 2.xlsx]Student Record'!$B$10

='D:SSR Sec and TechcertificatePath
[STUDENT 2.xlsx] File Name
Student Record'!$B$10 Sheet name and Cell reference

The formula works without any problem. I want to replicate the formula to extract the same data in multiple excel files. In this case only the second part of the formula needs to change to "STUDENT 3", "STUDENT 4", "STUDENT 5" and so on. I have created a column in excel with those values. I am trying to use the cell contents in the above "formula", but I cannot seem to replace this value in the formula. Needless to mention that I tried to drag the formula, but it does not work. I am attaching the two excel files.

View 3 Replies View Related

Copy Multiple Excel Files Into One File?

Jan 10, 2014

I am trying to combine 60 separate excel files into one main file. I've been opening each file copying it then pasting it into the main file.However, this is getting tiresome.

View 1 Replies View Related

Edit Multiple Excel Files Simultaneously?

Jul 6, 2011

I need to copy information from one excel file and paste it into the same location (A1-A1, B6-B6, etc) in many other files all at once. Essentially I have several thousand files that need to be updated right now. I need to copy and paste both the cell contents and the formatting.

View 1 Replies View Related

Search Through Multiple Excel Files And Get Data?

Mar 10, 2014

Currently using the following code to "pull" a range data from a closed workbook.

[Code] ......

This works well if I know which workbook and sheet I will be getting the info from. What I would like to do is add a function that searches through a few workbooks looking for a worksheet name that matches a value in a cell in my original workbook.

ie. Workbook 1, cell A1 = "Jelly"

search through excel files for the workbook that contains the worksheet named "Jelly" and then copy a range from that worksheet back to workbook 1.

View 2 Replies View Related

Import Multiple TXT Files Into Excel Sheets

Dec 6, 2012

I have some 400+ .txt tab delimit files in the same format in the same directory. All of them have 4 cols. I would like to use a VB sub code to import col1's of all .txt files to a workbook sheet1 filing from col1 to coln in excel sheet1. And col2's of all .txtx files to sheet2 of the same workbook. An so on. I found a code that can import the col1's from .txt files to excel sheet1 only. But not col2's to sheet2.

View 6 Replies View Related

Macro To Send Email With Active Excel Sheet Attached

May 21, 2014

How to modify the below vba code? It sends an email with an attachment right away after pressing the macro button. I would like the user to see the email in outlook before it gets send... and then press 'send' in Outlook .....

Sub Mail_ActiveSheet()
'Working in Excel 2000-2013
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
Dim FileExtStr As String
Dim FileFormatNum As Long

[Code] .....

View 1 Replies View Related

Macro To Send Email From Excel Through Outlook Basis Of Different Conditions

Aug 11, 2014

creating a macro to send email from excel through Outlook basis of different conditions and with embedded text and subject.

There 2 workbooks attached with this post. The workbook named "Data" contains the data and the workbook named "Emails" contains the Dealer Names (in Column A), the Email ids of the contact person (Column B, C and D), the subject (in Column E) and mail content (in Column F).

I need a Macro which first split the data basis of "Dealer Name" Column F into multiple sheets from "Data" sheet. Now, each sheet will contain only the Individual dealer's data. The data whose ageing is 2 or more than 2 days (in Column H) is highlighted in yellow.

Now, I need to send a separate email to dealers with their data details from range A to F (including headers) as an embedded text with subject and mail content which is present in "Emails" workbook.

Now the twist is, if any dealer having the Aging value in Column H is 2 or more than 2 days (highlighted in yellow color) than the email should be sent in CC to Column D email ids but if there is no Aging more than 2 days than the email should be sent in CC to Column C email ids.

"To" email ids (in Column B), subject (in Column E) and mail body (in Column F) will remain same in both conditions. Column A is containing the Dealer Names through which macro will identify the email ids.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved