Solved

vb script Microsoft Word tables portion of based on bookmark, count and add rows

Posted on 2016-09-20
1
82 Views
Last Modified: 2016-09-21
Screenshot of table in Word with Bookmark illuminated:  http://www.screencast.com/t/2BExLOfquY

How do I adapt the following so that it counts only the rows in the bookmark and adds a row within the bookmark:
Dim objShell, strPath, wd
Set objShell = CreateObject("Wscript.Shell")
Set wd = CreateObject("Word.Application")
wd.visible = true
strPath = objShell.CurrentDirectory
wd.Documents.Open strPath & "/MakeTableNew.docx"
set tbl  = wd.ActiveDocument.Bookmarks(1).Range.Tables(1)
msgbox tbl.rows.count  'returns 6, should return 3
tbl.rows.add()  'adds row to end of table, should add row to bookmark area
wd.ActiveDocument.SaveAs(strPath & "/MakeTableNewNew.docx")
wd.Quit

The purpose of this is that I plan to do the following steps:
Add bookmarks to a table representing a header, group header, multiple detail and footer regions similar to a report tool
Populate each region with financial data.
0
Comment
Question by:maxdbase
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 51

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41806838
Hi,

pls try

set tblPart = wd.ActiveDocument.Bookmarks(1).Range
 msgbox tblPart.rows.count  'returns 6, should return 3
 tblPart.rows.add()  'adds row to end of table, should add row to bookmark area

Open in new window

Regards
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Word is a program we have all encountered at some point, but very few of us have dug deep into its full scope of features, let alone customized it to suit our needs. Luckily making the ribbon (aka toolbar, first introduced in Word 2007) wo…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question