Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Fri Jul 14, 2017 7:46 am

presentation.LoadFromFile("D:\1\abc.potx")
Dim iSile = presentation.Slides.Count
Dim oSlide = presentation.Slides(0)
Dim oShape = oSlide.Shapes(0)

How can dupplicate object [oShape] to process?

daitranthanhhoa
 
Posts: 51
Joined: Mon Sep 19, 2016 3:04 am

Fri Jul 14, 2017 9:17 am

Hello,

Thanks for your inquiry.
Sorry there's no direct way to copy a shape at present. I have added it as a new feature into our schedule. Once there's any progress, I will let you know. Sorry for the inconvenience caused.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Fri Jul 14, 2017 10:37 am

Can i add a new Shape and all format the same old Shape?

daitranthanhhoa
 
Posts: 51
Joined: Mon Sep 19, 2016 3:04 am

Mon Jul 17, 2017 3:49 am

Hello,

Thanks for your response and sorry for the late reply.
Please refer to the following code to create a new slide using the format of the old shape.
Code: Select all
Dim presentation As New Presentation()
presentation.LoadFromFile("C:\Users\Administrator\Desktop\test.pptx")
Dim oSlide = presentation.Slides(0)
Dim oShape = TryCast(oSlide.Shapes(0), IAutoShape)
Dim st As ShapeType = oShape.ShapeType
Dim newSlide = presentation.Slides.Append()
'step1. copy the shape to the second slide, pay attention there's no format
Dim newShape As IAutoShape = newSlide.Shapes.AppendShape(st, New RectangleF(50, 50, oShape.Width, oShape.Height))

'step2. add the format to the shape
'copy the fill color
newShape.Fill.FillType = oShape.Fill.FillType
newShape.Fill.SolidColor.Color = oShape.Fill.SolidColor.Color
'copy the line color
newShape.Line.FillFormat.FillType = oShape.Line.FillFormat.FillType
newShape.Line.FillFormat.SolidFillColor.Color = oShape.Line.FillFormat.SolidFillColor.Color
'copy the text content
newShape.TextFrame.Text = oShape.TextFrame.Text
'copy the text color and text font
newShape.TextFrame.TextRange.Format.Fill.FillType = oShape.TextFrame.TextRange.Format.Fill.FillType
newShape.TextFrame.TextRange.Format.Fill.SolidColor.Color = oShape.TextFrame.TextRange.Format.Fill.SolidColor.Color
newShape.TextFrame.TextRange.LatinFont = oShape.TextFrame.TextRange.LatinFont
'copy the text font size
newShape.TextFrame.TextRange.FontHeight = oShape.TextFrame.TextRange.FontHeight

presentation.SaveToFile("11100.pptx", FileFormat.Pptx2010)

Attached are my sample file and the result file.
Moreover, I have to explain that I didn't suggest you using this method to duplicate a shape before because there might be some limitations if the shape is too difficult. Since you were asking again, I just share this code with you for a temporary solution. And our dev team is investigating if there's a direct way to copy an existing shape with the format, once there's any good news, I will notify you.
If I misunderstand you, please share your sample file with us and we will provide the solution accordingly.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.Presentation