-->
List of SendKeys in VBA

List of SendKeys in VBA

The SendKeys technique simulates keystrokes that you would manually performing in any window applications. Use with alert, since it can have unforeseen outcomes.

You must put activate window as whichever application you are automating through SendKeys.

Say for Example you are automating a e-mail item through excel macro which need to be send automatically in the time user specified. Assume that you are writing an important e-mail manually at the time of other Macro performing which consisting of SendKeys functions built in it.

May cause a result of sending wrong email item, instead of Macro sends. Because you are currently working one is the active item wherein the SendKeys going to perform.

To avoid this situation activate the specific application/mail item before Sendkeys perform.


Please find the below SendKeys List.

Key
Code
Backspace
{BACKSPACE} or {BS}
Break
{BREAK}
Caps Lock
{CAPSLOCK}
Clear
{CLEAR}
Delete or Del
{DELETE} or {DEL}
Down Arrow
{DOWN}
End
{END}
Enter (Numeric Keypad)
{ENTER}
Enter
~ (tilde)
Esc
{ESCAPE} or {ESC}
Help
{HELP}
Home
{HOME}
Ins
{INSERT}
Left Arrow
{LEFT}
Num Lock
{NUMLOCK}
Page Down
{PGDN}
Page Up
{PGUP}
Return
{RETURN}
Right Arrow
{RIGHT}
Scroll Lock
{SCROLLLOCK}
Tab
{TAB}
Up Arrow
{UP}
F1 through F15
{F1} through {F15}




You can also specify keys combined with SHIFT and/or CTRL and/or ALT. To specify a key combined with another key or keys, use the following table.
To combine a key withPrecede the key code with
SHIFT+ (plus sign)
CTRL^ (caret)
ALT% (percent sign)
Read more »
How to insert signature in Outlook Email through VBA macro

How to insert signature in Outlook Email through VBA macro

This is article about how to insert signature part into the outlook at once you created a new email through macro.

if you are working in a firm or somewhere else and you like to automate email creation part through the VBA macro you will face some kind of issue like your signature will be gone at once macro return body of the mail.

To solve the issue, on your macro code you are able to see ".Display" (it is a code which used to display email in front of the user instead of sending it automatically through macro).

Add the below code after ".Display" command. Which let you enable your signature automatically post your body of the mail.

'(After “.Display” comment)

SendKeys "{Tab}^+{End}{End}", True

Application.SendKeys ("%NAS~")
Application.Wait (Now + TimeValue("0:00:02"))

Thanks for coming☺️

Read more »
How to Avoid Outlook Security Warning Popup Message?

How to Avoid Outlook Security Warning Popup Message?

Do you still wondering is there a way to avoid "Security warning popup message"?

The answer is "Yes" if you are sending emails without using ".send" method in you code.

Assume that you going to create a new email in outlook through excel macro and you are using ".Send" method in your VBA code as a final command to send mail automatically without even displaying the mail item to the user.

But the outlook has inbuilt function to alert the user and get their concurrence to send the email.  For that it will show you the popup message as a warning that a "A program is trying to send e-mail message on your behalf, if this is unexpected, click Deny and verify your antivirus software is up-to-date. Provide a option like,do you really want to send, click "Allow" or else click "Deny" button.

Like below one.



Solution:

To ignore this problem instead of the ".Send" method in you macro use

.Display
Application.sendkeys "%s"

It will show original message for a second and then it will go without any prompt message as above.


Note:

Pros of Sendkys:

It will work on any applications you are trying to automate. Say for example if you are automating Skype and you want to send any text to type automatically, can use SendKeys here.

Ex: application.sendkeys "Hi"

Complete list Sendkeys list here

Cons of Sendkys:

The only problem using the SendKeys is, at the time it performs to the specific applications/mail items should be active. Otherwise SendKeys will work on the other applications whichever is active.


Other Scenario's you get prompt message

Except the .Send method, we have other scenario's wherein Outlook prompt message like "Allow" or "Deny".

  • Accessing/Extracting Recipients Details
  • Accessing/Extracting Body of the Mail Details

as mentioned above scenario's you are able avoid using the Third party applications/Addins if your firm ready provide access over it. Please refer the below sites for your reference. Through which you can completely eradicate this problem. There is no other way other than this from my knowledge.



Thanks for visit.

Read more »
How to Minimize/Maximize Outlook Mail Window?

How to Minimize/Maximize Outlook Mail Window?

Are you automating outlook through excel?

New Email Creation in Outlook

Situation: If you are automating procedure of creating multiple brand new outlook emails through excel and you may come across to the situation minimize the mail item once it created through macro.

Solution: Please use the below code to minimize/maximize the outlook mail item window.

The special one is that using the "getinspector" will make your job get done.


'Use the below code to Minimize/Maximize the Outlook mailtiem window

Sub MinimizeMaximizetheMail()
 Set OutApp = CreateObject("Outlook.Application")
 Set OutMail = OutApp.CreateItem(olmailitem)

'----------------------Creating content in a New Mail ------------------------
    
    With OutMail
        .to = "name@domain.com"
        .cc = "name1@domain.com"
        .bcc = "name2@domain.com"
        .Subject = "Test"
        .body = "Testing the mail"
        
        
 '----------------------Minimize/Squeeze/Maximize the mail item ------------------------
        Set ObjInspector = OutMail.getinspector   '-----Assigning current mail item to an object variable
        ObjInspector.Display       '----- This step will Display the mail in front of you. (Optional)
        ObjInspector.WindowState = 2        '----- Squeez the currently working mail.
        ObjInspector.WindowState = 1        '----- Minimize the currently working mail.
        ObjInspector.Display   '----------------- Maximize the mail again.
             

'----------------------Send your Mail ------------------------
        .send
             
    End With

End Sub
Read more »
How to Create New Outlook Email Through Excel VBA?

How to Create New Outlook Email Through Excel VBA?

Please copy paste the below code in to your "Module" and save it (change the content and address details as per your requirement). Assign a Button to that macro and click run. There you go.

(I have provided complete details how each one of the lines is working in VBA in the below codes itself. Once you pasted those details into the Module comments will be highlighted in green)

For your note we have not used any References to this Outlook Macro to run. This is called "Late Binding", which means we directly creating outlook application/mail item without altering or adding any References relating to Outlook in VBA editor. We are just directly telling to VBA to open outlook application through the below details

'Use the below code to Minimize/Maximize the Outlook mailtiem window

Sub CreateNewMail()
 Set OutApp = CreateObject("Outlook.Application")  '-------- Create Outlook application if not open already
 Set OutMail = OutApp.CreateItem(olmailitem) '---------Create new mail item to write a content you want
    
'----------------------Creating content in a New Mail ------------------------
    
    With OutMail '-----what are the actions you are going to perform with the new items will go here
        .to = "name@domain.com"  '---- Provide your To address details here.
        .cc = "name1@domain.com"  '---- Provide your CC address  details here.
        .bcc = "name2@domain.com"   '---- Provide your BCC address details here if required.
        .Subject = "Test"   '---- Provide your Subject Details here.
        .body = "Testing the mail"   '---- Write your content whatever you want to send.
        
'----------------------Send you Mail ------------------------
        .Display  '-------- This step will Display the mail item (Optional)
        .send   '----- This will send the mail item also it prompts security popup window. Once click "Allow" the message will go.
             
    End With

End Sub

Thanks for the visit.

Read more »
Home