INTRODUCTION

A conversation with Anna? Anna as Disney’s Frozen? Well no. So who is Anna?

Hmmm seems my question didn’t correspond by who is Anna. Or maybe I asked What is Anna?

Anna is not a human nor an animal, she is a program who was speaking in our last topic ( SpeakToMe: A Talking Excel or Talk to your Foolish Computer using Microsoft Excel )
“Microsoft Anna – English (United States) as the computer’s default voice.” – Microsoft Windows

Actually in our very first topic in SpeakToMe, we didn’t really talk to our computer, she was just a guide for helping us of what are the information she had. (although not totally information)
For this topic we will making a “VAMA – Very Annoying Mimic of Anna” – I just actually invented that acronym hehe.
This guide, Anna will speak whatever you wrote down in the input box.
 I’m gonna show you how.

SETTING UP YOUR VBA

Open your workbook (Microsoft Excel File)
Enable your Developer Tab (see here how to Show your Developer Tab on the ribbon)

You have to allow or enable the settings for macro to run the code

(File –> Option –> Trust Center –>Trust Center Settings –> Macro Settings –> Check “Enable all macros”)

HOW TO WORK IT OUT


Inserting Command Button

Insert CommandButton from the Developer Tab
Click Insert (Drop Down)
Under Active X Controls, click command button
This is how to Insert Command Button for Microsoft Excel
How to Insert Command Button




Writing the code

Double Click your Command Button (The Design mode must be enabled)
Design Mode is Enabled
Private Sub CommandButton1_Click()
MyMsg = InputBox(“Hello Boss!, Please write your words here”, “Write it down”) ‘*A
Set SpeakToMe = CreateObject(“sapi.spvoice”) ‘*B
SpeakToMe.Speak MyMsg ‘*C
End Sub
Paste this code to your code editor
It should be like this
Code




Testing your work

Close the code editor
Click your command button and test it out
Note: Make sure you have speakers or headset, and set it to right volume

Output Image

Output

Explanation

Private Sub CommandButton1_Click()
MyMsg = InputBox(“Hello Boss!, Please write your words here”, “Write it down”) ‘*A
Set SpeakToMe = CreateObject(“sapi.spvoice”) ‘*B
SpeakToMe.Speak MyMsg ‘*C
End Sub

*A: 
  • Here the Input Box will pop-up when you hit the Command Button.
  • MyMsg” is our variable here
  • Hello Boss!, Please write your words here”  is our prompt in the 1st procedure
  • And our title “Write it down” which in the header
  • In your Input Box that you typed, your words will be stored in our variable which MyMsg
  • Note: Store means, computer will store the data for later use(eg. you stored your food in your fridge for your meal, later)
*B:
  • Now setting up the variable which is SpeakToMe for creating of an object from the system of microsoft windows. This is very important procedure, without this we cannot use Anna or other computer voice as our speaker. See link below for more details.
  • https://msdn.microsoft.com/en-us/library/ms723602(v=vs.85).aspx
*C
  • Here, Anna will now speak our  stored words from input box
  • So let the variable SpeakToMe speaks (SpeakToMe.Speak)
  • And the words should be spoken is our variable which is MyMsg
  • SpeakToMe.Speak MyMsg

ADDITIONAL: Using Notepad

Now you have a VAMA – Very Annoying Mimic of Anna, not really annoying but amazing. Would you like to learn more? Well, you can use VAMA without needs of Microsoft Excel, just use notepad instead. Same procedure instead of opening your excel, open notepad and copy-paste this code below : Just exclude the private sub and end sub from the above code

MyMsg = InputBox(“Hello Boss!, Please write your words here”, “Write it down”) 
Set SpeakToMe = CreateObject(“sapi.spvoice”) 
SpeakToMe.Speak MyMsg 
VBS VAMA







Note: Be sure you saved it as .vbs (e.g., SpeakToMe VAMA vbs.vbs)

Run your file

DOWNLOAD SAMPLE FILE

(if you don’t trust these files, scan first using your anti-virus or anti-malware program)

Don’t forget to subscribe or follow me on google + for more future posts

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: