One of the scenario in my application requires "Change Picture"
functionality in powerpoint 2003. It is of course available in 2007 but not
in 2003. Some how I managed to incorporate the same kind of functionality in
2003.
Now the problem is when I select the image which needs to be changed and
apply "change picture" functionality, the dimensions are not same as that of
the former image. For example if the image that is selected have the
dimensions of 100X100 px, then the new image that was changed have 133X100
px. (The new image has the original dimensions of 1024X768 px.)
I have also tried to manually change the size of the picture in an image
editor in windows 7 having the same dimensions(1024X768 px) to 100X100 px.
The size automatically becomes 133X100 px.
Please help me in this regard with some needful stuff
Regards,
Praveen.
How exactly did you incorporate this functionality in PPT 2003?
Via VBA or some other type of code? If so, post the relevant portion.
Otherwise it's impossible to say what's going wrong.
Also, how are you measuring the image dimensions? PowerPoint doesn't use px
(pixels, I assume you mean) as a measurement system.
Thanks for the reply. I have done with ppt addin. The code would look like
this
static int nShapesCount = 0;
static int nSlideId = 0;
static IShape shape;
protected virtual void SlideSelectionChanged(ISlide slide, ISelection
selection)
{
....
if (slide != null)
{
if (slide.Slide.Shapes().Count == nShapesCount + 1 && shape
!= null && slide.Slide.SlideID == nSlideId)
{
Rectangle shapeRect = new Rectangle(shape.Bounds);//I
have created a class which holds the dimensions like width, height, top and
left. "shapeRect" holds the dimensions of the image that is selected
shape.Delete();//Deletes the selected image
slide.Shapes().GetShape(slide.Slide.Shapes().Count).Bounds =
shapeRect;//Places the new image with dimensions of old image which was
selected.
}
slide.SlideSelectionChanged();
IShape[] selectedShapes =
slide.Shapes().GetSelectedShapes();//to get selected image
if (selectedShapes.Length > 0)
{
shape = selectedShapes[0];
nSlideId = slide.Slide.SlideID;
}
else
{
shape = null;
}
nShapesCount = slide.Slide.Shapes().Count;
}
.........
}
The above gets executed as soon as the image is inserted onto the slide.
"Steve Rindsberg" wrote:
> .
>
In article <436644D0-C626-4D18...@microsoft.com>, Praveen wrote:
> Hi Steve,
>
> Thanks for the reply. I have done with ppt addin. The code would look like
> this
>
> static int nShapesCount = 0;
> static int nSlideId = 0;
> static IShape shape;
> protected virtual void SlideSelectionChanged(ISlide slide, ISelection
> selection)
> {
> .....
> if (slide != null)
> {
> if (slide.Slide.Shapes().Count == nShapesCount + 1 && shape
> != null && slide.Slide.SlideID == nSlideId)
> {
> Rectangle shapeRect = new Rectangle(shape.Bounds);//I
> have created a class which holds the dimensions like width, height, top and
> left. "shapeRect" holds the dimensions of the image that is selected
> shape.Delete();//Deletes the selected image
>
> slide.Shapes().GetShape(slide.Slide.Shapes().Count).Bounds =
> shapeRect;//Places the new image with dimensions of old image which was
> selected.
> }
> slide.SlideSelectionChanged();
> IShape[] selectedShapes =
> slide.Shapes().GetSelectedShapes();//to get selected image
> if (selectedShapes.Length > 0)
> {
> shape = selectedShapes[0];
> nSlideId = slide.Slide.SlideID;
> }
> else
> {
> shape = null;
> }
> nShapesCount = slide.Slide.Shapes().Count;
> }
> ..........