In order to automatically create (Table Of Contents)TOC, you need to do a few things before staring the process of actually making TOC.
While you are preparing your document you should use heading styles for chapter names, section names and subsection names. The depth of this hierarchy depends on your documents. A typical hierarchy would look like:
Chapter name
Section name
Subsection name
Content
It’s not necessary that you use sections and subsections. You could very well put content just under chapters without having any sections or subsections.
Go to the page where you want to put TOC. Put cursor at the point where TOC should begin.
Go to References tab > Click on Table of Contents button > Select a TOC style
Voila! Your table of content will appear with nice formatting and page numbers where chapters and sections are located.