Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-17-2015, 07:35 AM
milena milena is offline Adding ContentControl to a table Windows 7 64bit Adding ContentControl to a table Office 2013
Novice
Adding ContentControl to a table
 
Join Date: Apr 2015
Posts: 4
milena is on a distinguished road
Default Adding ContentControl to a table

I'm trying to add a row to a table. How can I add a date picker to one of the cells?


That's a part of the code that I have a problem with:

Code:
Sub addR()

Dim oTable As Table
Dim oCell As Cell
Dim oNewRow As Row
Dim oCCtrl As ContentControl

 ' Insert new row
    Set oTable = ActiveDocument.Tables(1)
    Set oNewRow = oTable.Rows.add

 For Each oCCtrl In ActiveDocument.ContentControls
        With oCCtrl
            If .Type = wdContentControlDate Then oNewRow.Cells(1).Range.Text = ""
        End With
  Next oCCtrl

End Sub
I'm not sure if I'm on the right path, but I would be grateful for any suggestions.

Thanks!
Reply With Quote
  #2  
Old 04-17-2015, 11:08 PM
gmayor's Avatar
gmayor gmayor is offline Adding ContentControl to a table Windows 7 64bit Adding ContentControl to a table Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

It is not the controls (which don't yet exist) that you want to cycle through, but the cells in the added row. e.g.

Code:
Sub addR()
Dim oTable As Table
Dim oCell As Cell
Dim oNewRow As Row
    'identify table
    Set oTable = ActiveDocument.Tables(1)
    ' Insert new row
    Set oNewRow = oTable.Rows.Add
    'identify the required cell in the new row
    Set oCell = oNewRow.Cells(1)        'the first cell in the row
    'add a date control to the cell
    ActiveDocument.ContentControls.Add wdContentControlDate, oCell.Range
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 04-20-2015, 01:04 AM
milena milena is offline Adding ContentControl to a table Windows 7 64bit Adding ContentControl to a table Office 2013
Novice
Adding ContentControl to a table
 
Join Date: Apr 2015
Posts: 4
milena is on a distinguished road
Default

Ahh ok! Thanks a lot!
Reply With Quote
Reply

Tags
content control, table



Similar Threads
Thread Thread Starter Forum Replies Last Post
Create UserForm ComboBox or ContentControl ptmuldoon Word VBA 11 01-17-2015 05:58 PM
Adding ContentControl to a table Adding Rows to a Table SuzeG Word VBA 8 01-02-2014 08:05 AM
Adding ContentControl to a table Trying to Reference a ContentControl Using DocProperty SuzeG Word VBA 4 12-17-2013 03:40 PM
Adding ContentControl to a table Activate/ select ContentControl czsti Word VBA 1 08-14-2013 08:32 AM
Adding ContentControl to a table adding table to a particular place hklein Word VBA 2 07-25-2011 01:45 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft