![how to insert a table in word how to insert a table in word](https://www.technicalcommunicationcenter.com/wp-content/uploads/2010/10/MS-Word-2010-Table-of-Figures-Dialog-Box1.jpg)
(How you create bookmarks is, again, beyond the scope of this tip by has been covered elsewhere in WordTips.)
![how to insert a table in word how to insert a table in word](http://2.bp.blogspot.com/-CFa1w9eDR-Q/VlQykuqZi4I/AAAAAAAAKXM/E9uj9Q_lhRI/w1200-h630-p-k-no-nu/1.png)
(How you create and apply styles is beyond the scope of this tip, but has been covered extensively in other WordTips.) Once you are done creating all the styles for your headings, you'll need to apply those styles to the actual headings in your document.
![how to insert a table in word how to insert a table in word](https://img.webnots.com/2018/05/Adding-Table-of-Contents-Automatically-with-Pre-installed-Styles.png)
For example, you might use styles named “Chapter1Heading1”, “Chapter1Heading2”, and so on for the first chapter, and “Chapter2Heading1”, etc., for the second chapter. What you want to do is to create a set of styles for the headings you want included in each TOC. The easiest way to create multiple tables of contents is to use styles. Thus, you can have a table of contents for each chapter of a book, even if all the chapters are in the same document. Shading.Word allows you to include multiple tables of contents in a single document. Shading.ForegroundPatternColor = wdColorAutomatic With oTable.Rows(1).Range 'we can now apply some beautiness to our table :) OTable.Cell(x, y).Range.Text = oExcelRange.Cells(x, y).Value Set oTable = (Range:=, NumRows:=nNumOfRows, NumColumns:=nNumOfCols) 'create table and asign it to variable Set oExcelRange = oExcelWorksheet.Range("A1:C8") Set oExcelWorksheet = oExcelWorkbook.Worksheets(1) 'asign first worksheet to variable Set oExcelWorkbook = (strFile) 'open workbook and asign it to variable Set oExcelApp = CreateObject("Excel.Application") StrFile = "c:\Users\Nenad\Desktop\BookSample.xlsx" 'change to actual path This VBA example will make a table from an Excel file: Sub MakeTablefromExcelFile()ĭim oExcelApp, oExcelWorkbook, oExcelWorksheet, oExcelRangeĭim x As Long, y As Long 'counter for loops 'display result from cell from second column in second rowĮnd Sub Create Word Table From Excel File NCounter = nCounter + 1 'increases the counter Set oTable = (Range:=, NumRows:=3, NumColumns:=3) 'create table and asign it to variableįor Each oRow In oTable.Rows ' outher loop goes through rowsįor Each oCell In oRow.Cells 'inner loop goes This VBA macro will loop through all cells in a table, writing the cell count to the cell: Sub TableCycling()ĭim nCounter As Long ' this will be writen in all table cellsĪ 'just makes new para athe end of doc, Table will be created here