View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Help with CDO mail

Gina,

If you set the MultiSelect parameter of GetOpenFilename to True, you can
select more than one file from the Open dialog. The selected files will be
returned as an array of individual file names. Thus, you can use code like
the following to test for 0, 1, or many files selected by the user.

Dim FName As Variant
Dim N As Long
Dim OneFName As String

FName = Application.GetOpenFilename(MultiSelect:=True)
If IsArray(FName) Then
For N = LBound(FName) To UBound(FName)
OneFName = FName(N)
' attach file named in OneFName
Debug.Print OneFName
Next N
Else
If FName = False Then
' user cancelled
Debug.Print "User selected 0 files"
Else
Debug.Print "User selected 1 file: " & FName
End If
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Gina K" wrote in message
...
That works great - thanks!
As a follow up question: if I want to attach multiple files, would I use
an
FName2, FName3, etc., or is there a better way?

"Chip Pearson" wrote:

You can prompt the user for the full file name with one dialog:

Dim FName As Variant
FName = Application.GetOpenFilename()
If FName = False Then
' user cancelled
Exit Sub
End If

Now, you have the complete file name in the variable FName which you can
use
to attach the file.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)