[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Modify table cell in winword via automation

Posted on 2016-11-10
3
Medium Priority
?
81 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 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Suggested Courses

826 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