Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 12-25-2015, 07:29 AM
gmaxey gmaxey is offline adding tables based on a number given in a form Windows 7 32bit adding tables based on a number given in a form Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Replace Person 1 with Person {Seq TblNum}
Note that is a sequence field and the braces are created using Ctrl+F9

Bookmark the entire Person # paragraph and table.

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Range
Dim oTbl As Table
Dim lngIndex As Long
  Set oRng = ActiveDocument.Bookmarks("PersonTable").Range
  oRng.Copy
  oRng.Collapse wdCollapseEnd
  oRng.InsertBefore vbCr
  oRng.MoveStart wdParagraph, 1
  For lngIndex = 1 To ActiveDocument.FormFields("Tekst1").Result - 1
    oRng.Paste
    oRng.Collapse wdCollapseEnd
    oRng.InsertBefore vbCr
    oRng.MoveStart wdParagraph, 1
  Next
  ActiveDocument.Fields.Update
lbl_Exit:
  Exit Sub
End Sub
Attached Files
File Type: dotm QuestionForum.dotm (25.9 KB, 18 views)
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 

Tags
form field, table, word vba.



Similar Threads
Thread Thread Starter Forum Replies Last Post
adding tables based on a number given in a form Automatically adding new rows based on form field tejaspareek Word VBA 4 04-17-2015 05:35 AM
Adding sums from simuliar tables from different sheets. LameDuck Excel 0 12-04-2014 08:57 PM
adding tables based on a number given in a form Adding text to after a bookmark based on drop down menu choice ksigcajun Word VBA 6 06-10-2014 09:39 AM
Maximum Number Of Styles-Based-On? Pluviophile Word 13 05-08-2014 05:29 AM
finding data from different tables based on header s7y Excel 3 11-11-2013 09:09 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft