Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Attaching files to emails using a wildcard
To Whom it may concern,
I am using an Excel 2003 marco to create a number of emails, with attached files. The files I am attaching follow a "format", are CSV type, and are unique to the folder, but are not sequential, eg., CML_1234567.csv. I've tried a few versions of the following code (without success); .Attachments.Add (PathtoFile & strFileA & "CML" & "*" & ".csv") & .Attachments.Add (PathtoFile & strFileA & "CML" & "*.csv") How can I use a "Wildcard" to select a file for attachment to an email? TIA Andrew from Telstra |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Attaching files to emails using a wildcard
Hi Andrew
Not sure if this is what you are after. It sounds like you are trying to allow the user to select the file to attach to the email? Taken from the VBE help fileToOpen = Application _ .GetOpenFilename("Text Files (*.txt), *.txt") If fileToOpen < False Then MsgBox "Open " & fileToOpen End If Ammend the above to your file type, and ammend the code to attach the file. Apologies if this is not what you are after HTH "Andrew@Telstra" wrote: To Whom it may concern, I am using an Excel 2003 marco to create a number of emails, with attached files. The files I am attaching follow a "format", are CSV type, and are unique to the folder, but are not sequential, eg., CML_1234567.csv. I've tried a few versions of the following code (without success); .Attachments.Add (PathtoFile & strFileA & "CML" & "*" & ".csv") & .Attachments.Add (PathtoFile & strFileA & "CML" & "*.csv") How can I use a "Wildcard" to select a file for attachment to an email? TIA Andrew from Telstra |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Attaching files to emails using a wildcard
Hello Steve,
Unfortunately, this is not entirely what I am looking for. I do not want the user (me) to select the file to be attached to the email. I want the macro to select the file to be attached to the email, and attach it. The only thing that is consistant with the file's naming convention, is the initial qualifier (CML), and the extension (.csv). I have another macro that opens a file with a similar naming convention. In that case, the file's name is Orderyyyymmddhhmmss (ie., date & time). Since the time is variable, I use the astericks as a wildcard to open the file; Workbooks.OpenText Filename:= PathToFile & "Order" & FileDate & "*" This code works very well, and I thought that Excel's VBA would allow me to use a version of it to attach semi-consistant files to emails. Are you able to shed more light on my problem? TIA Andrew from Telstra "steve_doc" wrote in message ... Hi Andrew Not sure if this is what you are after. It sounds like you are trying to allow the user to select the file to attach to the email? Taken from the VBE help fileToOpen = Application _ .GetOpenFilename("Text Files (*.txt), *.txt") If fileToOpen < False Then MsgBox "Open " & fileToOpen End If Ammend the above to your file type, and ammend the code to attach the file. Apologies if this is not what you are after HTH "Andrew@Telstra" wrote: To Whom it may concern, I am using an Excel 2003 marco to create a number of emails, with attached files. The files I am attaching follow a "format", are CSV type, and are unique to the folder, but are not sequential, eg., CML_1234567.csv. I've tried a few versions of the following code (without success); .Attachments.Add (PathtoFile & strFileA & "CML" & "*" & ".csv") & .Attachments.Add (PathtoFile & strFileA & "CML" & "*.csv") How can I use a "Wildcard" to select a file for attachment to an email? TIA Andrew from Telstra |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Attaching files to emails using a wildcard
Hi Andrew
Part of the problem as I see it is how will your Macro "know" which specific file to attach if there are more than 1 file present in the folder? Try the following link, and F8 through it http://www.excelkb.com/article.aspx?...3&cNode=5V1C8G slowly modify the above procedure to suit your needs. I am sadly unable to Test as I don't run Outlook HTH "Andrew@Telstra" wrote: Hello Steve, Unfortunately, this is not entirely what I am looking for. I do not want the user (me) to select the file to be attached to the email. I want the macro to select the file to be attached to the email, and attach it. The only thing that is consistant with the file's naming convention, is the initial qualifier (CML), and the extension (.csv). I have another macro that opens a file with a similar naming convention. In that case, the file's name is Orderyyyymmddhhmmss (ie., date & time). Since the time is variable, I use the astericks as a wildcard to open the file; Workbooks.OpenText Filename:= PathToFile & "Order" & FileDate & "*" This code works very well, and I thought that Excel's VBA would allow me to use a version of it to attach semi-consistant files to emails. Are you able to shed more light on my problem? TIA Andrew from Telstra "steve_doc" wrote in message ... Hi Andrew Not sure if this is what you are after. It sounds like you are trying to allow the user to select the file to attach to the email? Taken from the VBE help fileToOpen = Application _ .GetOpenFilename("Text Files (*.txt), *.txt") If fileToOpen < False Then MsgBox "Open " & fileToOpen End If Ammend the above to your file type, and ammend the code to attach the file. Apologies if this is not what you are after HTH "Andrew@Telstra" wrote: To Whom it may concern, I am using an Excel 2003 marco to create a number of emails, with attached files. The files I am attaching follow a "format", are CSV type, and are unique to the folder, but are not sequential, eg., CML_1234567.csv. I've tried a few versions of the following code (without success); .Attachments.Add (PathtoFile & strFileA & "CML" & "*" & ".csv") & .Attachments.Add (PathtoFile & strFileA & "CML" & "*.csv") How can I use a "Wildcard" to select a file for attachment to an email? TIA Andrew from Telstra |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Attaching files to emails using a wildcard
Hello Steve,
You're right: the problem is making the macro know what specific file it needs to attach. I've copied the code to the macro, because I like the idea of using the same code to create many different emails. So I'll have a good look at it. I'm sure if I take it slowly, I'll understand what's happening. And if I discover how to attach the files, I'll let you know. Thanks Andrew from Telstra. "steve_doc" wrote in message ... Hi Andrew Part of the problem as I see it is how will your Macro "know" which specific file to attach if there are more than 1 file present in the folder? Try the following link, and F8 through it http://www.excelkb.com/article.aspx?...3&cNode=5V1C8G slowly modify the above procedure to suit your needs. I am sadly unable to Test as I don't run Outlook HTH "Andrew@Telstra" wrote: Hello Steve, Unfortunately, this is not entirely what I am looking for. I do not want the user (me) to select the file to be attached to the email. I want the macro to select the file to be attached to the email, and attach it. The only thing that is consistant with the file's naming convention, is the initial qualifier (CML), and the extension (.csv). I have another macro that opens a file with a similar naming convention. In that case, the file's name is Orderyyyymmddhhmmss (ie., date & time). Since the time is variable, I use the astericks as a wildcard to open the file; Workbooks.OpenText Filename:= PathToFile & "Order" & FileDate & "*" This code works very well, and I thought that Excel's VBA would allow me to use a version of it to attach semi-consistant files to emails. Are you able to shed more light on my problem? TIA Andrew from Telstra "steve_doc" wrote in message ... Hi Andrew Not sure if this is what you are after. It sounds like you are trying to allow the user to select the file to attach to the email? Taken from the VBE help fileToOpen = Application _ .GetOpenFilename("Text Files (*.txt), *.txt") If fileToOpen < False Then MsgBox "Open " & fileToOpen End If Ammend the above to your file type, and ammend the code to attach the file. Apologies if this is not what you are after HTH "Andrew@Telstra" wrote: To Whom it may concern, I am using an Excel 2003 marco to create a number of emails, with attached files. The files I am attaching follow a "format", are CSV type, and are unique to the folder, but are not sequential, eg., CML_1234567.csv. I've tried a few versions of the following code (without success); .Attachments.Add (PathtoFile & strFileA & "CML" & "*" & ".csv") & .Attachments.Add (PathtoFile & strFileA & "CML" & "*.csv") How can I use a "Wildcard" to select a file for attachment to an email? TIA Andrew from Telstra |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
attaching toolbars to files | Excel Programming | |||
Attaching Emails in Outlook Message Format | Excel Discussion (Misc queries) | |||
Attaching PDF files | Excel Discussion (Misc queries) | |||
Truble Attaching PDF Files | Excel Programming | |||
Attaching Files to Emails | Excel Programming |