Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
attaching toolbars to files Papa Jonah Excel Programming 4 October 15th 08 06:17 PM
Attaching Emails in Outlook Message Format Marie FP[_2_] Excel Discussion (Misc queries) 1 June 23rd 08 07:01 PM
Attaching PDF files Neil Meehan Excel Discussion (Misc queries) 0 September 23rd 06 04:29 AM
Truble Attaching PDF Files Chaplain Doug Excel Programming 0 September 13th 05 02:36 PM
Attaching Files to Emails Ben Excel Programming 1 November 18th 04 01:52 AM


All times are GMT +1. The time now is 01:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"