View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Andrew@Telstra Andrew@Telstra is offline
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