Solved

Modify table cell in winword via automation

Posted on 2016-11-10
3
28 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
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 …

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now