![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Location: rejdus@hotmail.com
Posts: 18
|
i was given a mcros which would open outlook and prepare to get ready to send an email.the macro is shown below:
Sub SendEmailNR() ' ' SendEmailNR Macro ' ' Dim aOutlook As Object, aEmail As Object On Error Resume Next Set aOutlook = GetObject(, "Outlook.Application") On Error GoTo INoOutlook If aOutlook Is Nothing Then Set aOutlook = CreateObject("Outlook.Application") Set aEmail = aOutlook.CreateItem(olMailItem) On Error GoTo 0 aEmail.Subject = "Latest figures" aEmail.Body = "The figures do not include the last two days of trading." aEmail.Attachments.Add ThisWorkbook.Path & "\data01.xls" On Error GoTo INoSend aEmail.Recipients.Add "bigman@address.com" aEmail.Send MsgBox "Email successfully sent" Exit Sub INoSend: MsgBox "Microsoft Outlook is not installed" End Sub error message: COMPILE ERROR. LABEL NOT DEFINED. this hapeens when i run it step by step by pressing F8 any idea wot could go wrong? |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Yeah, you're error message is telling it to go to a label that doesn't exist. ("INoOutlook" in this case)
Change the line of code that says:
to
|
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Location: rejdus@hotmail.com
Posts: 18
|
aEmail.Attachments.Add ThisWorkbook.Path & \As~project~withoutpics.xls
okay next problem accuried in this line. error msg is The system cannot find the file specified. its probably talking about As~project~withoutpics.xls that.isnt? well i duno wot other specified file i should give. givin up ... begging 4 help |
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Quote:
I'm assuming that you changed the code yourself to the name of the workbook you're trying to send. Basically the error is saying that the workbook "As~project~withoutpics.xls" doesn't exist, at least not in the same directory as the file you've got this VBA in. My suggestion is to check the filepath of the workbook the code is in and the location of the "As~project~withoutpics.xls" file. HTH |
|
|
|
|
|
|
#5 |
|
New Member
Join Date: Mar 2002
Posts: 33
|
you didn't forget the quotes "" around the file name did you?
|
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
|
Yeah, I noticed that but it didn't register. Good catch.
_________________ [b] Mark O'Brien [ This Message was edited by: Mark O'Brien on 2002-04-11 14:26 ] |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Apr 2002
Location: Cape Town,South Africa
Posts: 234
|
Try This my friend
Sub EMAIL() Mailee = InputBox("Please Enter Name to Send sheet to.........") subj = InputBox("Please enter eMail Subject..............") Application.Dialogs(xlDialogSendMail).Show arg1:="", arg2:="As Requested" Recipients = Mailee.Subject = subj.Close End Sub hope it works::::did not check it first |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|