![]() |
#1
|
|||
|
|||
![]() Can anyone give me some VBA coding advice to select one of many listed quickparts table place holder and then Add a title msgbox and source to be completed and "insert table" menu to select number of columns and rows. I have my default table style set up to apply styles. Thanks ![]() |
#2
|
|||
|
|||
![]()
To insert a named building block from the Built-In Building Blocks.dotx file you can use:
Code:
Sub InsertBuildingBlock() Dim oTmp As Template Templates.LoadBuildingBlocks For Each oTmp In Templates If UCase(oTmp.Name) = "BUILT-IN BUILDING BLOCKS.DOTX" Then Exit For End If Next oTmp If Not oTmp Is Nothing Then oTmp.BuildingBlockTypes(wdTypeTables).Categories("Built-in").BuildingBlocks("With Subheads 1").Insert Where:=Selection.Range, RichText:=True End If lbl_Exit: Exit Sub End Sub You could create your own custom building block in that template or gallery with the correct title and number of rows/columns. |
#3
|
|||
|
|||
![]()
Thanks for your reply.
I would like the user to be able to select which quickpart table to use as we have many options, so would like a message box to appear listing options to choose from then add how many rows and columns as these vary and not set. |
#4
|
|||
|
|||
![]()
Well a quick part is just a saved table. Once you insert it in the document you could then add or delete columns.
Say your create and save a simple two row X one column table as quickpart in the tables gallery "Built-In" category of the Building Blocks.dotx file. You could then use something like this: Code:
Sub InsertBuildingBlock() Dim oTmp As Template Dim oRng As Range Dim oTbl As Table Dim lngRows As Long, lngCols As Long Templates.LoadBuildingBlocks For Each oTmp In Templates If UCase(oTmp.Name) = "BUILDING BLOCKS.DOTX" Then Exit For End If Next oTmp If Not oTmp Is Nothing Then Set oRng = oTmp.BuildingBlockTypes(wdTypeTables).Categories("Built-in").BuildingBlocks("Basic Table").Insert(Where:=Selection.Range, RichText:=True) Set oTbl = oRng.Tables(1) oTbl.Cell(1, 1).Range.Text = InputBox("Enter the table title", "TITLE") lngRows = InputBox("Enter the number of rows", "ROWS", 1) lngCols = InputBox("Enter the number of columns", "COLUMNS", 2) oTbl.Cell(2, 1).Split lngRows, lngCols oTbl.Style = "Plain Table 1" End If lbl_Exit: Exit Sub End Sub |
![]() |
Tags |
insert word table, vba, word vba macro |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
markg2 | Word Tables | 9 | 02-09-2020 02:25 PM |
Insert a Excel table in an existing PowerPoint table | Vallin | PowerPoint | 1 | 03-09-2015 06:25 AM |
![]() |
Kapoof | Excel | 1 | 02-18-2014 02:12 PM |
![]() |
rphox2003 | Word | 10 | 03-06-2013 11:13 PM |
Insert table in document - automatically updates second table in summary? | Mechanic | Word | 2 | 08-01-2012 09:44 PM |