Link to home
Start Free TrialLog in
Avatar of Stephen Byrom
Stephen ByromFlag for Ireland

asked on

Content control in Word

Hi,
I have a couple of ContentControls in a Word document that I wish to reset to the first item in the list when the user clicks a button.
I have the button and some code to clear the contents of table cells, and I have tried to get the first contentcontrol (a drop list) to reset to the first list item, (line 15 in the code) but I'm struggling.
As always any help is much appreciated.
Private Sub btnEmal_Click()
On Error GoTo ErrHandler
    Dim cl1 As Cell
    Dim cl2 As Cell
    Dim tbl As Table
    Dim rng As Range
    
    Set tbl = ActiveDocument.Tables(1)
    Set cl1 = tbl.Cell(2, 2)
    Set cl2 = tbl.Cell(11, 5)
    Set rng = cl1.Range.Duplicate
    rng.End = cl2.Range.End
    rng.Delete
    
ActiveDocument.Range , ContentControls("Shift").Range = 1
Exit Sub
ErrHandler:
    MsgBox Err.Description
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stephen Byrom

ASKER

Brilliant!
Did exactly what I wanted.
Thanks a lot