crazy mayk with crazy email macro.
crazy mayk with crazy email macro.
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 7 of 7

Thread: crazy mayk with crazy email macro.

  1. #1
    New Member
    Join Date
    Mar 2002
    Location
    rejdus@hotmail.com
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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. #2
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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:


    INoSend:


    to


    INoOutlook:


  3. #3
    New Member
    Join Date
    Mar 2002
    Location
    rejdus@hotmail.com
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #4
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-11 14:02, Mayk wrote:
    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
    I don't see that line of code in your original sample, I see this line though:


    aEmail.Attachments.Add ThisWorkbook.Path & "data01.xls"


    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. #5
    New Member
    Join Date
    Mar 2002
    Posts
    33
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    you didn't forget the quotes "" around the file name did you?

  6. #6
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #7
    Board Regular
    Join Date
    Apr 2002
    Location
    Cape Town,South Africa
    Posts
    234
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    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

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com