Alex said:
Hi all.
How can I replace picture in content control without losing content
control's (picture) format? (MS Word 2007)
Thanx
If you just want to trigger the content control's Change Picture command and
let the user choose the picture, use something like this:
Sub x()
Dim cc As ContentControl
Set cc = ActiveDocument.ContentControls(1)
If cc.Type = wdContentControlPicture Then
'Debug.Print cc.Range.InlineShapes.Count
cc.Range.Select
Dialogs(wdDialogInsertPicture).Show
End If
End Sub
If you know what file you want to insert and just want to do the whole thing
in the macro, use something like this:
Sub y()
Dim cc As ContentControl
Set cc = ActiveDocument.ContentControls(1)
If cc.Type = wdContentControlPicture Then
If cc.Range.InlineShapes.Count > 0 Then
cc.Range.InlineShapes(1).Delete
End If
ActiveDocument.InlineShapes.AddPicture _
FileName:="e:\pictures\bunnycakes.jpg", _
linktofile:=False, Range:=cc.Range
End If
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.