Solved

Modify table cell in winword via automation

Posted on 2016-11-10
3
52 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 500 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 44

Author Comment

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

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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.
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 …
Suggested Courses

739 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