Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

code obviate necessity click

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Code to obviate necessity to click when sending a copy via outlo

Code to obviate necessity to click when sending a copy via outlo

ResolvedVersion 2007

John has attended:
Excel VBA Intro Intermediate course
Excel VBA Intro Intermediate course

Code to obviate necessity to click when sending a copy via outlo

How can I avaoid the need to click on 'approved' when sending an email via outlook.

RE: Code to obviate necessity to click when sending a copy via o

Hi John, thanks for your query. What you need is the "Sendkeys" keyword to mimic the user pressing "OK". Have a look at this tutorial:

http://www.tek-tips.com/faqs.cfm?fid=5037

...and particularly here where the Enter key is sent by code to a messagebox:

http://en.allexperts.com/q/Excel-1059/VBA-5.htm

There are other, more complicated, ways of doing this as I think I mentioned when we met but try Sendkeys out first and see how you get on.

Hope this helps,

Anthony

RE: Code to obviate necessity to click when sending a copy via o



Hi Anthony

This is the Sub Routine I am using:

Sub ApprovedForPayment()
'Sends the Workbook to 'pl@sussexdowns.ac.uk'
Dim Location As String
Location = Sheets("Payments").Range("$H$2")

Application.DisplayAlerts = False

ActiveWorkbook.SendMail "pl@sussexdowns.ac.uk", Subject:=Location & " Homestay Payments Approved for Payment"

Application.DisplayAlerts = True
End Sub

The process stops at the sendmail command and I am presented with the message that an aplication outside Outlook wants to send a message and option to 'Allow' or 'Deny' with the 'Deny' button as the default option. There is also a 'Help' button.
I can use 'Tab' key and 'Enter to 'Allow' but so far I have been unable to make the 'SendKeys' function work; when stepping throu the subroutine processing is halted until an option is selected.
Where am I going wrong?
I would be grateful for your help with this please.

John

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Applying and removing border from cell in Excel 2010

Did you know the shortcut key for applying and removing the outline border for a cell?

CTRL+SHIFT+& Applies the outline border to the selected cells.
CTRL+SHIFT_ Removes the outline border from the selected cells.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.