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

x
?
Solved

Modify table cell in winword via automation

Posted on 2016-11-10
3
Medium Priority
?
76 Views
Last Modified: 2016-11-12
I'm filling in a winword document with a table via automation (VBA, access database).  The automation code moves to a bookmark and inserts text at that point.  Everything works perfectly.
Now there is a requirement to change the border of a cell that has a specific bookmark in the cell in a word table.  Two parts to the problem.
  • How do I identify and select the table cell based on it containing a bookmark?
  • Once I have the cell selected how would I modify one of the cell borders (change the line style)?
0
Comment
Question by:AndyAinscow
[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
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 41882747
Here is a some sample code:
Sub ModifyCellBorder()
    Dim cl As Word.Cell
    Dim doc As Document
    
    Set doc = ActiveDocument
    Set cl = doc.Bookmarks("MyBookmark").Range.Cells(1)
    cl.Borders(wdBorderLeft).LineStyle = wdLineStyleDashDot
End Sub

Open in new window

0
 
LVL 45

Author Comment

by:AndyAinscow
ID: 41882821
Thanks, I'll give it a try tomorrow and get back.
0
 
LVL 45

Author Closing Comment

by:AndyAinscow
ID: 41884611
Just needed to qualify doc as Word.Document and then worked perfectly.  Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
Suggested Courses

609 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