Hi, Jay.
It seems that I hastened to the findings.
First of all, this code fails on some end user computers, but it doesn't on
my developer's machine.
I changed it as follows (C#):
InlineShape sh = ctrl.Range.InlineShapes[1];
Range rng1 = sh.Range;
rng2 = ctrl.Range;
object direction = WdCollapseDirection.wdCollapseEnd;
rng2.Collapse(ref direction);
int i = rng2.Move(ref unit, ref cnt);
rng1.Select(); //this line was added
Application.Selection.Copy();
rng2.Select(); //this line was added
rng2.Paste();
Shape shape = rng2.InlineShapes[1].ConvertToShape();
After adding range selection, the code started to work normally on other
computers.
But then I got another error:
If content control is located in the header (footer), then there is an
exception "Index refers beyond end of list." at:
rng2.InlineShapes[1].ConvertToShape();.
Should I use another way to manipulate content controls in header?
Thanks in advance.
I was try to replace the picture in the content control. The content control was in the footer of the doc. The code given in the site works when the content control is not in footer.
The below code works even in the footer
ActiveDocument.SelectContentControlsByTag("newfooter").Item(1).Range.InlineShapes.Item(1).Delete
ActiveDocument.InlineShapes.AddPicture _
FileName:="C:\Sunil\Images\logo3.bmp", _
linktofile:=False, Range:=ActiveDocument.SelectContentControlsByTag("newfooter").Item(1).Range
Note: newfooter is the name of the picture content control.
> On Monday, February 01, 2010 7:57 AM Alex wrote:
> Hi all.
> How can I replace picture in content control without losing content
> control's (picture) format? (MS Word 2007)
>
> Thanx
>> On Monday, February 01, 2010 9:53 AM Jay Freedman wrote:
>> If you just want to trigger the content control's Change Picture command and
>> let the user choose the picture, use something like this:
[quoted text clipped - 31 lines]
>> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
>> all may benefit.
>>> On Monday, February 01, 2010 11:10 AM Alex wrote:
>>> Thanks for your response, Jay.
>>>
[quoted text clipped - 6 lines]
>>> But this method is not very nice. Besides, I cannot find some properties (e.g
>>> rotation angle).
>>>> On Monday, February 01, 2010 10:30 PM Jay Freedman wrote:
>>>> Well, this is the word.VBA.general group. Questions about automating
>>>> Word from outside VBA are often posted to the word.programming group,
[quoted text clipped - 52 lines]
>>>> oShp.Rotation = rot
>>>> End Sub
>>>>> On Tuesday, February 02, 2010 7:15 AM Alex wrote:
>>>>> Thank you, Jay.
>>>>> This code works perfect.
>>>>>
>>>>> "Jay Freedman" wrote:
>>>>>> On Friday, February 05, 2010 2:53 AM Alex wrote:
>>>>>> Hi, Jay.
>>>>>> It seems that I hastened to the findings.
[quoted text clipped - 25 lines]
>>>>>>
>>>>>> Thanks in advance.
>>>>>> Submitted via EggHeadCafe
>>>>>> Statistics, Probability, Lotteries and Dumb Programmers
>>>>>> http://www.eggheadcafe.com/tutorials/aspnet/041de19a-e704-468f-bd3c-79164fc739f5
/statistics-probability-lotteries-and-dumb-programmers.aspx