PC Review


Reply
Thread Tools Rate Thread

Attaching files to emails using a wildcard

 
 
Andrew@Telstra
Guest
Posts: n/a
 
      11th Jul 2007
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 With Quote
 
 
 
 
=?Utf-8?B?c3RldmVfZG9j?=
Guest
Posts: n/a
 
      11th Jul 2007
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 With Quote
 
Andrew@Telstra
Guest
Posts: n/a
 
      12th Jul 2007
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" <(E-Mail Removed)> wrote in message
news:C8C42E94-6149-4184-852D-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?c3RldmVfZG9j?=
Guest
Posts: n/a
 
      12th Jul 2007
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" <(E-Mail Removed)> wrote in message
> news:C8C42E94-6149-4184-852D-(E-Mail Removed)...
> > 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 With Quote
 
Andrew@Telstra
Guest
Posts: n/a
 
      13th Jul 2007
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" <(E-Mail Removed)> wrote in message
news299B462-7E8C-4C76-BDB5-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:C8C42E94-6149-4184-852D-(E-Mail Removed)...
>> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Attaching zip files to emails SAS Microsoft Outlook Discussion 2 14th Sep 2009 08:41 PM
RE: Attaching files to emails Wendy Microsoft Access 1 30th Mar 2006 10:15 AM
Attaching files to emails Wendy Microsoft Access 5 27th Mar 2006 09:25 AM
Attaching Files to Emails =?Utf-8?B?QmVu?= Microsoft Excel Programming 1 18th Nov 2004 01:52 AM
Attaching files to emails Cameron Windows XP Networking 1 7th Jan 2004 11:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:55 PM.