+ Reply to Thread
Results 1 to 5 of 5

How do I stop a warning dialog box from popping up, using VBA

  1. #1
    Registered User
    Join Date
    01-24-2013
    Location
    Tunbridge Wells, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Question How do I stop a warning dialog box from popping up, using VBA

    Hi. This is my first post, and a bit of a noob question, so apologies. I have written a short VBA routine to send an email automatically from within Excel. However, when I run it, I need to intervene manually when a dialog box pops up warning me that "A program is trying to automatically send e-mail on your behalf - Do you want to allow this?". The options are Yes, No and Help.

    I have tried Application.DisplayAlerts = False and also Application.DoCmd.SetWarnings False, but neither of these works.

    Can anyone tell me please, is there another way to stop this box from raining on my parade, or perhaps to give an automatic 'Yes' response when it does?

    Many thanks.

    Ian.

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: How do I stop a warning dialog box from popping up, using VBA

    It is probably the code you are using to send the e-mail.
    There are some that do this, however there are various code that allow e-mail to be sent without the protection.
    It would help if you posted your code or uploaded an example workbook with the code in.
    What e-mail acount are you using? most codes work mainly with outlook
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Registered User
    Join Date
    01-24-2013
    Location
    Tunbridge Wells, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: How do I stop a warning dialog box from popping up, using VBA

    Thanks Sean,

    I am indeed using Outlook 2003. The code that I am using is:

    Sub email()
    Dim myol As New Outlook.Application
    Dim myemail As Outlook.MailItem

    Set myemail = myol.CreateItem(olMailItem)
    myemail.To = "[email protected]"
    myemail.Subject = "Test email from Excel"
    myemail.BodyFormat = olFormatHTML
    myemail.Body = "Test"

    myemail.Send

    End Sub


    Anything you can suggest will be appreciated, thanks.

    Ian.

  4. #4
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: How do I stop a warning dialog box from popping up, using VBA

    hi, it works ok on mine. no warning box appears.

    try this code, you dont need a reference to outlook for ths code

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-24-2013
    Location
    Tunbridge Wells, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: How do I stop a warning dialog box from popping up, using VBA

    Thanks for this Sean. Even with your code I still get the warning from Outlook. I have run my code without any problems on another machine, so I think the problem may be solved by making sure I have the same edition of Excel as Outlook, that way they should play nicely together.
    Thanks again for your help.
    Ian.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1