View Single Post
 
Old 02-03-2011, 07:50 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,343
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi verbster,

The document you referred to has a single table with cells containing Picture and Rich Text Content Controls, but it has no facility for adding a new page full of these.

Assuming your document is constructed with a table containing rows for the Picture and Rich Text Content Controls, the following macro will generate a new pair of rows with these same controls. You'll probably need to redefine the row sizes to suit your needs. Note that the code uses both the CentimetersToPoints and InchesToPoints conversions - you can use either (or neither).
Code:
Sub Demo()
Dim ocel As Cell
With ActiveDocument.Tables(1)
  If MsgBox("Add a new row?", vbYesNo, "Picture Manager") = vbYes Then
    .Range.Rows.Add
    .Rows.Last.Height = CentimetersToPoints(5.75)
    For Each ocel In .Rows.Last.Cells
      ocel.Range.ContentControls.Add (wdContentControlPicture)
    Next
    .Range.Rows.Add
    .Rows.Last.Height = InchesToPoints(0.25)
    For Each ocel In .Rows.Last.Cells
      With ocel.Range.ContentControls
        .Add wdContentControlRichText
        With .Item(1)
          .Tag = "Photo Caption"
          .PlaceholderText = "Type image caption here."
        End With
      End With
    Next
  End If
End With
End Sub
You could also modify the code with a loop to insert a whole page full of these. As coded, the macro already takes care of however many columns there are in the table.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote