How to Learn New Quote Every Day by Adding a “Quote of the Day” Feature in Your Word

In today’s post, we want to explain the way to add a “Quote of the Day” feature in your Word to learn new quote every day.

The feature “Quote of the Day” shows one different quote each time you start Word. Just take seconds to read a quote of wisdom before you burying yourself in tons of work. This shall do you much good.Adding a "Quote of the Day" Feature in Your Word

Therefore, follow our leads to add such a feature in your Word now.

Put Quotes in an Excel File

  1. First of all, open Excel and rename a new sheet as “Quotes”.
  2. Next input “Number” in cell A1, “Quotes” in cell B1, and “Times” in cell C1.
  3. Then fill column A with serial numbers.
  4. Add one quote in each cell in column B.
  5. And input number “0” in column C.Create an Excel Sheet->Rename the Sheet
  6. Lastly, name the Excel file as “Quote of the Day”. And save it in a folder. In our case, after we saved the file, its full address shall look like as below:
C:\Users\Public\Documents\Sample\Quote of the Day.xlsx

Accordingly, you should remember yours.

You can click here to download a sample file.

Insert a Module in VBA Project

  1. To begin with, trigger VBA editor in Word by pressing “Alt+ F11”.
  2. On the “Project” panel on the left, click “Normal”.
  3. Then click “Insert” tab on the menu bar.
  4. And choose “Module” on the drop-down menu.Click "Normal"->Click "Insert"->Click "Module"
  5. Next double click to open the new module.
  6. Now paste following codes there:
Sub AutoExec()
  Dim objExcel As Excel.Application
  Dim objWorkbook As Excel.Workbook
  Dim objWorksheet As Excel.Worksheet
  Dim nRowIndex As Integer
  Dim nMinValue As Integer
  Dim nMinRowIndex As Integer
 
  Set objExcel = CreateObject("Excel.Application")
  Set objWorkbook = objExcel.Workbooks.Open("C:\Users\Public\Documents\Sample\Quote of the Day.xlsx")
  Set objWorksheet = objWorkbook.Sheets("Quotes")
 
  ' Initialization
  nMinValue = 0
  nMinRowIndex = -1
 
  For nRowIndex = 2 To objWorksheet.UsedRange.Rows.Count
    If (nMinRowIndex = -1) Then
      nMinValue = objWorksheet.Cells(nRowIndex, 3).Value
      nMinRowIndex = nRowIndex
    Else
      If (objWorksheet.Cells(nRowIndex, 3).Value < nMinValue) Then
        nMinValue = objWorksheet.Cells(nRowIndex, 3).Value
        nMinRowIndex = nRowIndex
      End If
    End If
  Next nRowIndex
 
  frmQuoteOfTheDay.txtQuoteOfTheDay.text = objWorksheet.Cells(nMinRowIndex, 2).Value
  frmQuoteOfTheDay.Show Modal
 
  objWorksheet.Cells(nMinRowIndex, 3).Value = objWorksheet.Cells(nMinRowIndex, 3).Value + 1
 
  objWorkbook.Close SaveChanges:=True
  ' Close Excel using Quit method on the Application object.
  objExcel.Application.Quit
  '  Release the object variable.
  Set objExcel = Nothing
End Sub
  1. Click “Save” button.Paste Codes->Click "Save"

Note:

In this code line:

Set objWorkbook = objExcel.Workbooks.Open("C:\Users\Public\Documents\Sample\Quote of the Day.xlsx")

Remember to replace the path address with an actual one.

Insert a User Form

Next we will create a user form to show the quote.

  1. Still, in VBA editor, click “Insert” tab again.
  2. Only this time, you choose “UserForm”.
  3. Then you will have a user form. Click on the form handles to resize it.
  4. Next press “F4” to open “Properties” window. It will appear on the left-down corner of the screen.
  5. Name the form as “frmQuoteOfTheDay” and set its caption as “Quote of the Day”. Besides, set font and background color properly. And choose “False” for the “ShowModal”.Name the Form->Set the Caption
  6. Then click “Toolbox” command on menu bar to bring out the box.
  7. Use the controls to create a text box, a label, and a command button. Arrange them in following order:Click "Toolbox"->Insert a Label, a Text Box and a Command Button
  8. Next you ought to set properties for these controls.
  • First, click on label. Set the caption text as “Quote of the Day”. Apply proper font size and set the background as transparent.
  • Second, click on text box. Name it as “txtQuoteOfTheDay”.
  • Third, click on command button. Name it as “btnClose” and set caption as “Close”. Then double click on the “Close” button to open coding area. Enter following codes:
Private Sub btnClose_Click()
  Unload Me
End Sub
  1. Finally, save codes.

Each time you start Word, you will see a user form such as below:A User Form Showing the Quote

Fix Word Problems

It’s inevitably to encounter with this or that issue in Word which might lead to a corrupted document. The most important thing is to handle each crisis quickly and properly. This, however, will require a professional tool to recover docx.

Author Introduction:

Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including damaged Excel and pdf repair software products. For more information visit www.datanumen.com

Leave a Reply

Your email address will not be published. Required fields are marked *