Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change 12/23/2002 to 12-23-2002

Status
Not open for further replies.

thegameoflife

Programmer
Dec 5, 2001
206
US
for some reason vba does not like 12/23/2002 when attaching an attachment in outlook. So how can I change the date to mm-dd-yyyy?

Code:
Function mail_report()
Dim oMailApp As Outlook.Application
Dim oMail As Outlook.MailItem
Dim Reportname As String

Reportname = "C:\Data\Reports\HighDollar\HighDollar for " & Date & ".xls"

    Set oMailApp = CreateObject("Outlook.Application")
    Set oMail = oMailApp.CreateItem(olMailItem)
    With oMail
        .TO = "HighDollar"
        .Subject = "Report Test"
        .Body = "HighDollar Report              "
        .Importance = olImportanceLow
        .Sensitivity = olPrivate
        .Attachments.Add Reportname
        .Display
        '.Send
    End With

End Function
 
Hi

1 Your problem is you cannot have slashes in a filename, think about it, \ denotes folder

2 Use Reportname = "C:\Data\Reports\HighDollar\HighDollar for " & Foant(Date,"mm-dd-yy") & ".xls"

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top