Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2016-09-20
1
Medium Priority
?
98 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 53

Accepted Solution

by:
Rgonzo1971 earned 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
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.
Suggested Courses

604 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