Auto Email Directory From VBA Macro
Aug 11, 2006I got a task from my lab to write a macro in excel to "automatically email the detailes of the file listing from c: dir "
View 7 RepliesI got a task from my lab to write a macro in excel to "automatically email the detailes of the file listing from c: dir "
View 7 RepliesI 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?
I have a macro to send emails to a group people that based on various criteria, it will attach a number of files to a recipient's particular email. This is a small portion of the code that does the attachment adding:
Code:
If Range("B" & a) = "Y" Then
If citChev "" Then .Attachments.Add citChev
End If
If Range("C" & a) = "Y" Then
If citMits "" Then .Attachments.Add citMits
End If
If Range("D" & a) = "Y" Then
If citToyo "" Then .Attachments.Add citToyo
End If
If Range("E" & a) = "Y" Then
[code].....
Most people get several of the files attached to their email and all works fine. But, there are certain conditions when all the IF() stmts fail where a recipient will not get any files attached. I do not want to send the email if this is the case, but it currently is sending it.
Is there a way after all the IF() stmts have processed to check to see if this current email has any attachments assigned to it? (IF .Attachments "" Then...) does not work.
I currently have a button then when pressed automatically sends a summary report taken from the first page of Sheet 1.
Worksheet needs to be protected all the time, but Macro only works on an unprotected worksheet.
I was wondering what additional code and where to put in so that when
protected back again after Macro has been executed?
Here’s the Macro taken from [url]
I have an excel sheet which contains Supplier certs issue date and date of expiry of a particular cert. I would like to send an email to user when the date of expiry is met. I have very little knowledge or no knowledge of coding in VB. I want to send the email 30 days before the cert expire. i have attached the file.
SupplierCertificatesForm.xlsx‎
I can get it to work with 1 email and 1 condition but not 2.
Sub auto_open()
ThisWorkbook.Worksheets("Sheet1").OnEntry = "DidCellsChange"
End Sub
Sub DidCellsChange()
Dim KeyCells As String
KeyCells = "A1:A99"
If Not Application.Intersect(ActiveCell, Range(KeyCells)) _
Is Nothing Then KeyCellsChanged
End Sub ................................
I need to send an email when value of timer in column F exceeds 72 hrs. E-mail address of recipient is in column C and 2 fixed addresses are to be put in C.C.
basic outline would be
name(A) work(B) E-Mail(C) Work Started (D) Work Finished(E) Time Elapsed for Work from Start (F)
Can this emails be sent to repeat also after 24 hrs if the timer in F is not stopped (i.e till no entry is put into Column E)?
look at the script im running in the attached spreadsheet. It auto generates an email to the email address in c so long as column H has a yes in it. However there are things i would like to change. I would like it to say: contact xxx to discuss your outstanding resource center loan titled: {then put the title of the load in here - column E} which was due back on {then put due back date here column G}.
View 4 Replies View RelatedI wrote this code years ago to Auto Send Emails from Outlook...
Sub Emailfile()
Dim OutlookApp As Object
Const olMailItem = 0
Set OutlookApp = CreateObject("Outlook.Application")
Dim EmailContent As String
With OutlookApp.CreateItem(olMailItem)
EmailContent = Range("A1").Value
.To = "Test"
.Subject = "LSG Data File"
.Body = EmailContent
.Attachments.Add ("P:MI TeamICCE LEADS EXTRACTSLSGLSG Data File")
End With
End Sub
I can't figure out how to get it working for Lotus notes... So 2 things I guess really... Firstly is it possible? Second: If it is, how can I get it to send say 16 emails each with a specific attachment but the same commentary?
It copies one of the work books, Saves it and then emails this as an attachement to a few people.
All users are on Excel 2010, however the file originally was created in Excel 2003. The File Extension Was .xls as was the attachment.
First time I sent the email this year it came through corrupt. No changes had taken place in the workbooks or the code.
I have now updated the spreadsheet and saved it as a .xlsm
I have also updated the code so the attachments are .xlsx
The email attachments are always corrupt.
Code:
Sub copy2()
Application.ScreenUpdating = False
Dim fname As String 'filename
Sheets(Array("To Order", "WO To Chase", "PO To Chase", "Contact", "WO Report")).Copy
fname = Year(Date) & " " & Month(Date) & Day(Date) & " Chase & Order" 'filename!!
ActiveWorkbook.SaveAs FileName:= _
[code]...
where the corruption might come from? Its not via the email as if I go to the saved file its corrupt as well.
I created folder on my desktop to hold various documents. I have master excel document which contains forms and command buttons that open documents from same folder. Is there a way to change code instead of having full file path to specify current directory. I'm worried that if I move this folder to another location then my open file button will not work since location is changed.
Also when I open with command button word document, I have a button on word document to close. I can close document but word application is still active. Can I close word application with the document at the sam time. This is the code I'm using: "ActiveWindow.Close"
I need to send an email reminder to teachers on the day they have duty. I know how to set up an email that sends on a certain date, but I am unsure how to code it when the date changes. I have attached the spreadsheet.
In cell A 53, I have the date November 24th. In cell C53, I have the email address of the teacher doing duty that day. In cell F53, I have the date November 25th. In cell, I53 I have the email address of the teacher performing duty that day. On November 24th, the person in C53 should receive a reminder email. On November 25th, the person in cell I53 should receive a reminder email. I will have spreadsheet for every month of the year. So there will be LOTS of changing dates. How do I code this when the date keeps changing?
I send these kind of mails to intimate people about upcoming meeting, the format I prepare in Excel 2013 and paste it in Outlook 2013 (as a table, not as an image)
Now one of the columns I put as 'Days Remaining' which basically tells the users how many days are there to the review, the image below will show how it looks:
Now the numbers of days remaining will be correct the day I send the mail, but when somebody opens the mail at a later date, it would not sort of show the true number.
Is there a way to auto-update this number inside the Outlook mail, as it works in an Excel Sheet?
The title pretty much sums it up, actually. I have a macro, and a beautiful piece of work it is. It selects a particular selection of the active workbook, parses it in a particularly thrilling way, and writes the result to a text file. I'd like it to do this for ALL the files in a particular directory (somewhere over 500 files, if that matters).
View 2 Replies View RelatedThe code bellow allows me to save a copy of the invoice by way of doPDF using invoice number as the name of the pdf to be saved.
Code:
Else
Application.ActivePrinter = "doPDF v7 on DOP7:" 'Selects doPDF to genarate PDF file of invoice.
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= "E:LusaGenerated InvoicesINV" & Range("L17").Text & ".pdf", _
[Code]...
As there is the need to, should a quotation or an invoice be wrong, to change it. In other words I have code to cancel the invoice as bellow.
Code:
Dim sResponse As String
Dim rFound As Range
sResponse = InputBox("Enter record you want to change." & vbNewLine _& "ATTENTION!
This will change the current record number and will erase record data from saved records sheet.")
If sResponse = "" Then --cancelled or OK with no entry: do nothing or add message
Else
Set rFound = Sheet1.Columns("L").Find(What:=sResponse, LookIn:=xlValues,
[Code]...
The code above simply removes a line on sheet1 to which yet another macro retrieved some info from an invoice such as date, invoice, customer and total.
Now I just realized that when I change an invoice, I will be again when finished, creating another pdf file that already exists.
How can I have the second macro here changed so that it will go to ""E:LusaGenerated InvoicesINV" & Range("L17").Text & ".pdf", _" and delete this pdf file?
I have a 2 columns.
A: Current location Ex(C:UsersDesktoplabelsA02FAA.jpg)
B: Future location Ex(C:UsersDesktopoxes98300SA02FAA.jpg)
I want to move jpgs from location A to B
is there a way to execute this with a macro?
I would like to make a button that, when clicked, opens the following directory in a seperate window: "C:Documents and SettingssharkfootDesktopTNT" Here is what I tried...
Sub OpenLocker()
ActiveWorkbook.FollowHyperlink Address:="C:Documents and SettingssharkfootDesktopTNT"
End Sub
Because I am still a novice and because i wrote this myself, it doesn't work.
The script collects all the files in directory and sub-directories and list them in ascending format, I want them to get in transpose format. like for example: Root folder has many sub directories and in them a sub directory XYZ has 5 excel files, it will get the sub directory name in Col A and transpose all .xls files.
Col A | Col B________|Col C_________ |Col D___________|Col E________|
XYZ__|C:/root/test.xls|C:/root/Sales.xls |C:/root/Report.xls |C:/root/sam.xls|
[URL]
This Macro (Located within "SWMS Auto-Fill.xlsm) scans the folder its in and transfers information into select cells within each .xlsm file it finds. However I need to move the SWMS Auto-Fill.xlsm file to the parent directory.
So I need it to scan: Workbook DirectorySection4
Code is below:
VB:
Sub Autofill_SWMSs()
Dim MyPath As String
Dim MyFile As String
Dim Wkb As Workbook
Dim Cnt As Long
[Code]....
i'm looking for a macro which within a sheet named "foldernamedump" will list in a column the folder names within a directory I specify. I have seen a couple of sample codes but I just cant seem to get them working at all so I think its best to start from scratch and the work i get supplied here is always perfect. I also want the macro to clear the contents of the sheet before it loads again just to ensure there is no old data within the sheet.
View 5 Replies View RelatedI have recorded the below code that functions fine from my computer. My issue is that I need to export/import this macro to other workstations who may have the save to location mapped to a different drive letter. Is there a way to replace the drive letter with the URL (SharePoint)?
ChDir "E:3. CRQsRemedy Dumps"
ActiveWorkbook.SaveAs Filename:="E:3. CRQsRemedy DumpsToday_CRQ_8Dump.xls" _
, FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Save To Directory: \server_1Dir_1Dir_2FolderToday_CRQ_8Dump.xls
Permissions are in place.
I am continuing to struggle with my first attempt at a macro, and wonder if someone would mind taking a look to see where I have gone wrong? All I am trying to do is create file copying tool where the user can define the source and destination directory in workbook cells, and assign the macro to a button to complete the copy of all files from source to destination.
The macros do this:
Source and Location directory defined in Sub Archive1.
These are passed to file copy macro Sub ArchiveScript.
This macro checks for presence of destination directory, ensures that the directory backslash is in place, specfies the variables fn and fn2 to make sure the filecopy command copies all files in the directory, and then carries out the filecopy function itself.
However, I am getting two errors from the code that I can't figure out (I am still very much a beginner!)
- Invalid procedure call or element on fn = dir() at the bottom
- The copy still works, but only seems to copy one file from the source to the destination, and not all of them.
I would like a macro that saves the current open workbook to a directory specified in a cell on the open work sheet.
View 4 Replies View RelatedI am trying to query Active Directory for a list of user attributes by using a list of usernames and output the results into column B,C,D.....
All the usernames are listed in column A and it ranges from 100 to 1000 usernames.
The macro GetAdsProp works but it is very slow because it's a function and every time it gets called to return a value, it takes a long time to query. It will take forever to get 1000 users.
I've also tried the code below, however one of the AD attribute that I am querying for has a dash (i.e. test-address) and I can't put a dash in the vba code because it automatically puts spaces in between the dash and the text (see red text below) which will fail to find the attribute. Also, I need it to loop the whole column A and not just one account.
Sub LoadUserInfo()
Dim x, objConnection, objCommand, objRecordSet, oUser, skip, disa
Dim sht As Worksheet
' get domain
Dim oRoot
Set oRoot = GetObject("LDAP://rootDSE")
[Code] .....
Need macro to search approx 1000+ xls files in folder/directory for common text string "see reference" and then output the file number which is located in cell A1 to new spreadsheet for each file the text "see reference" is found.
View 2 Replies View RelatedWhat i am trying to do is in 1 workbook (labled as Book1 literally), it needs to copy the sheets out of every .xls file there is in a single directory, we'll call C:MyFolderMySubFolder. There can be anywhere between 1 and 366 files in this particular folder and I need all the sheets in each file labled 'CC' copy that entire sheet, paste that sheet to Book1, go back to that file it was copied from, close it (saving changes is ok), then move on to the next file.. and the next file... and so forth
While pasting into book1, I need each WS copied from each file to paste to a new worksheet in book1 rather than combining them into 1 or overwriting, and lable each of those sheets the file name of which the sheet came from...
The names are in sequence. All files in the folder will be labled as a date such as "9-6-12" so the sheet name in book1 would be named 9-6-12. (so there may result in 366 new worksheets to book1)
I primarily use Microsoft Office Excel 2003
Read “My Documents” Path And Use Result
Problem:
Note:
Typical user OS will be Windows XP Pro / Win 2K
Excel version : 97 / 2002 / 2003
1. Corporate network security settings will only allow directory/subdirectory creation in the “My Documents” section of customers individual computers.
2. Per customer request, VBA application needs to save extracted files for future use.
3. I can specify an initial “My Documents” subdirectory be made and the VBA application file be loaded/copied into that location – i.e. – “My DocumentsCat”.
4. When VBA application is opened from that specified directory, (first time), the application needs to make an additional subdirectory tree to save future files. I can read the opened from location via VBA with the following:
Dim filepath As String
filepath = ThisWorkbook.Path
As an example – this code would produce a string definition of “filepath” – such as the following:............................
I am trying to prompt the user for the directory to be saved in and file name to be saved as; then save the workbook in the input directory with the inputted file name.
View 3 Replies View RelatedI need to write an Email macro. It need to check all the dates and mail me the names of the persons whos medical will expire in 30 days.
View 9 Replies View RelatedI want a macro to take all the headed data from each row and put it on an email with the headed data and the filled data beside it on the outlook email.
View 14 Replies View Related