In this article, we will show you how to add a “Word of the Day” feature in your Word as to learn new word every day.
“Word of the Day” is a common feature of many online dictionaries. Then wouldn’t it a better thing that you can learn new words each time you starting Word? Today, we will zero in on showing how to achieve so.
Create an Excel File First
The first thing you need do is to create an Excel file, with all the following requirements met.
- Firstly, start Excel. Enter “Number” in cell A1, “Word” in cell B1, and “Times” in cell C1.
- Secondly, fill the first column with serial numbers.
- Thirdly, input all words you want to learn in the second column.
- And type “0” (number) in the third column.
- Next select the third column by clicking on letter “C”.
- Right click and choose “Format Cells”.
- In “Format Cells” box, under “Number” tab and select “Number” for category.
- Then choose “0” for decimal places and click “OK”.
- Next rename the worksheet as “Words”.
- Finally, save and name the Excel file as “Word of the Day”.
In our case, we save the file under the following folder:
You can click here to download a sample file.
Alter and Save Codes in Word VBA
- First and foremost, open Word and press “Alt+ F11” to trigger VBA editor.
- Next click “Normal” and then “Insert” on toolbar.
- Choose “Module” on the drop-down menu of “Insert”.
- Double click module to open it and paste the following codes there:
Sub AutoExec() Dim objExcel As Excel.Application Dim objWorkbook As Excel.Workbook Dim objWorksheet As Excel.Worksheet Dim nIndex As Integer Dim nMinValue As Integer Dim nMinIndex As Integer Set objExcel = CreateObject("Excel.Application") Set objWorkbook = objExcel.Workbooks.Open("C:\Users\Public\Documents\Sample\Word of the Day.xlsx") Set objWorksheet = objWorkbook.Sheets("Words") ' Initialization nMinValue = 0 nMinIndex = -1 For nIndex = 2 To objWorksheet.UsedRange.Rows.Count If (nMinIndex = -1) Then nMinValue = objWorksheet.Cells(nIndex, 3).Value nMinIndex = nIndex Else If (objWorksheet.Cells(nIndex, 3).Value < nMinValue) Then nMinValue = objWorksheet.Cells(nIndex, 3).Value nMinIndex = nIndex End If End If Next nIndex frmWordOfTheDay.txtWordOfTheDay.text = objWorksheet.Cells(nMinIndex, 2).Value frmWordOfTheDay.txtWordOfTheDay.Font.Size = 12 frmWordOfTheDay.Show Modal objWorksheet.Cells(nMinIndex, 3).Value = objWorksheet.Cells(nMinIndex, 3).Value + 1 objWorkbook.Close SaveChanges:=True ' Close Excel with the Quit method on the Application object. objExcel.Application.Quit ' Release the object variable. Set objExcel = Nothing End Sub
- Click “Save” to save codes.
Find this code line:
Set objWorkbook = objExcel.Workbooks.Open("C:\Users\Public\Documents\Sample\Word of the Day.xlsx")
Replace the path with your own one.
Create a User Form in Word
Since running the macro shall return a word with its meanings and usage example, it would be more user-friendly to create a user form instead of a message box.
- After you save codes in module, click “Insert” again and choose “UserForm” this time.
- Now you will get a user form. Click on handles around the form to adjust its size.
- Next click “View” on toolbar and select “Toolbox” to bring it out.
- Click “Properties Window” on toolbar or press “F4” to have it open at down-left corner. Adjust its size as need.
- In the first column of the property window, find “Name” and “Caption”. And enter name and description you like in the second column respectively. For example, we set the form name as “frmWordOfTheDay”, and enter “Word of the Day” for caption.
- Next in the toolbox, click the “Label” button with letter A on it.
- Use cursor to drag a label of proper size.
- Similarly, set the label name, caption, font and fore color in the property window.
- Next add a text box and command button to the form, and set their properties as well. Remember to set “MultiLine” as “True” if you text cover several lines. Here we name the text box as “txtWordOftheDay”.
- Double click on “Close” to open coding area. And enter “Unload Me”, such as bellow:
- Now go back to the “AutoExec” macro, and fins the following code lines:
frmWordOfTheDay.txtWordOfTheDay.text = objWorksheet.Cells(nMinIndex, 2).Value frmWordOfTheDay.txtWordOfTheDay.Font.Size = 12 frmWordOfTheDay.Show Modal
Among them, the “frmWordOfTheDay” is the name of the user form, and “txtWordOfTheDay” is the name of text box. Therefore, replace them with the names you actually use.
In the future, every time you start Word, you shall see a user form, showing you the word of the day. You can close it by clicking “Close”.
Carefully Handle Your Word Document
Since Word is vulnerable to errors, your documents become the number one victim. Thus, you must handle carefully with documents, especially when they get corrupt. At that time, you shall get a qualified Word recovery tool.
Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including damaged xls and pdf repair software products. For more information visit www.datanumen.com