How to insert a blank slide and add textbox with texts to it?


Hi, Support:

I want to insert a new blank slide into the head of an existing presentation, and then add one or two textbox to the new inserted slide, and then add texts to the new added textboxs. How to do it in
Thanks for your help!




Can you please visit this documentation link. This will help you to achieve your requirements. If there is still an issue than please share source file inform of presentation so that we may further investigate to help you out.


What is the link?
Would you please show me a demo codes here? Thanks very much!



Can you please visit this link now. Also please visit this link as well for adding text box.


Thanks for your reply.
I’ll be highly appreciated if you can share a demo codes for me.



I like to inform that the documentation link that we have shared with you have actual working code examples that you can try right away. Can you please share he we may help you further in this regard.


Thanks for you suggestion. But I still do not work it out by the reference.

It’s best if you could share me a demo for it.




I suggest you to please try using following sample.

Public Shared Sub AddBlankSlide()
    Dim pres As Presentation = New Presentation()
    Dim slide As ISlide = pres.Slides.AddEmptySlide(pres.LayoutSlides.GetByType(SlideLayoutType.Blank))
    Dim shape As IAutoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 100, 100)
    shape.FillFormat.FillType = FillType.NoFill
    Dim textFrame As ITextFrame = shape.AddTextFrame("")
    Dim paragraph As IParagraph = textFrame.Paragraphs(0)
    paragraph.Text = "This is sample text...."
    pres.Save("C:\Aspose Data\Savedpres.pptx", Aspose.Slides.Export.SaveFormat.Pptx)
End Sub


Thanks very much!
And other question is that how to format the fontname ,font size,font color,font italic of the text?



Can you please elaborate your query in more details. According to my understanding you want to remove font styling and size of text in box and set it to default.


Thanks for your reply. My queries are:

  1. How to insert a blank slide as the first slide to an existing presentation;
  2. then add two textboxes to the first blank slide, and then set the new position and size for the two textboxes, for example, the position of textbox1 is (50,50) and its size is (400,200), and the position of textbox2 is (50,300) and its size is (400,100).
  3. set the filltype of textboxes to NoFill
  4. set the border of textboxes to none
    5.add text to the textboxes, for example, the texts for adding to the textbox1 is “This is the title”, and the texts for adding to the textbox2 is “This work is done by Smith” , and then set the fontname(such as Arial), fontsize(such as 60), fontcolor(such as Red), fontbold for the added text in the textboxes
    6.add a back picture to the first slide, and then set the picture behind the text, and set the size of the back picture to the size of pagesize of the slide.

How to complete the codes to reach this goal?




I have shared sample code with you. This will help you to achieve your requirements. You may adjust settings like boxsize, fontsize according to your own requirements.

Using pres As Presentation = New Presentation(path & “Testsample.pptx”)
Dim slide As ISlide = pres.Slides.AddEmptySlide(pres.LayoutSlides(1))
Dim ashp As IAutoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 250, 150, 200, 100)
ashp.FillFormat.FillType = FillType.NoFill
Dim ashp1 As IAutoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 200, 100, 250, 150)
ashp1.FillFormat.FillType = FillType.NoFill
ashp.AddTextFrame(" “)
ashp1.AddTextFrame(” ")
Dim txtFrame As ITextFrame = ashp.TextFrame
Dim txtFrame1 As ITextFrame = ashp1.TextFrame
Dim para As IParagraph = txtFrame.Paragraphs(0)
Dim para1 As IParagraph = txtFrame1.Paragraphs(0)
Dim portion As IPortion = para.Portions(0)
Dim portion1 As IPortion = para1.Portions(0)
portion.Text = “This is the title”
portion.PortionFormat.FontHeight = 40
portion.PortionFormat.FontBold = NullableBool.[True]
portion.PortionFormat.FillFormat.FillType = FillType.Solid
portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Blue
portion1.Text = “This work is done”
portion1.PortionFormat.FontHeight = 60
portion1.PortionFormat.FontBold = NullableBool.[True]
portion1.PortionFormat.FillFormat.FillType = FillType.Solid
portion1.PortionFormat.FillFormat.SolidFillColor.Color = Color.Red
pres.Save(path & “TextBox_outsampleresult123.pptx”, Aspose.Slides.Export.SaveFormat.Pptx)
End Using


Thank you very much!
But your codes is not well matched with my desired output.
Please refer to the attachment, could you rewrite the demo codes to generate the DesiredOutput.ppt based on the Input.ppt and Backpic.jpg?

Thanks! (209.9 KB)



I have observed your desired output presentation and have created a sample project generating the desired output. However, I request you to please explore our online documentation as it contains readily available working sample fulfilling your requirements. If you find any issue while using documentation, please feel free to share with us.

Public Shared Sub AddBlankSlide()
    Dim path As String = "C:\Aspose Data\Test\"
    Dim pres As Presentation = New Presentation(path & "Input.ppt")
    Dim layout As ILayoutSlide = pres.LayoutSlides.GetByType(SlideLayoutType.Blank)

    If layout Is Nothing Then
        layout = pres.LayoutSlides.Add(pres.Masters(0), SlideLayoutType.Blank, "Blank")
    End If

    Dim slide As ISlide = pres.Slides.AddEmptySlide(layout)
    pres.Slides.Reorder(0, slide)
    Dim img As System.Drawing.Image = CType(New Bitmap(path & "BackPic.jpg"), System.Drawing.Image)
    Dim imgx As IPPImage = pres.Images.AddImage(img)
    Dim picFrame As IPictureFrame = slide.Shapes.AddPictureFrame(ShapeType.Rectangle, 20, 15, 692, 493, imgx)
    Dim box1 As IAutoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 14, 21, 647, 152)
    Dim box2 As IAutoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 14, 384, 647, 170)
    box1.FillFormat.FillType = FillType.NoFill
    box2.FillFormat.FillType = FillType.NoFill
    box1.LineFormat.FillFormat.FillType = FillType.NoFill
    box2.LineFormat.FillFormat.FillType = FillType.NoFill
    Dim textFrame1 As ITextFrame = box1.AddTextFrame("")
    Dim textFrame2 As ITextFrame = box2.AddTextFrame("")
    Dim paragraph1 As IParagraph = textFrame1.Paragraphs(0)
    paragraph1.ParagraphFormat.Alignment = TextAlignment.Left
    Dim paragraph2 As IParagraph = textFrame2.Paragraphs(0)
    paragraph2.ParagraphFormat.Alignment = TextAlignment.Left
    Dim portion1 As IPortion = paragraph1.Portions(0)
    Dim portion2 As IPortion = paragraph2.Portions(0)
    Dim portFormat1 As IPortionFormat = portion1.PortionFormat
    portFormat1.FillFormat.FillType = FillType.Solid
    portFormat1.FillFormat.SolidFillColor.Color = Color.Yellow
    portFormat1.LatinFont = New FontData("Arial")
    portFormat1.FontHeight = 20
    portFormat1.FontItalic = NullableBool.[False]
    portFormat1.FontUnderline = TextUnderlineType.None
    portFormat1.FontBold = NullableBool.[True]
    Dim portFormat2 As IPortionFormat = portion2.PortionFormat
    portFormat2.FillFormat.FillType = FillType.Solid
    portFormat2.FillFormat.SolidFillColor.Color = Color.Yellow
    portFormat2.LatinFont = New FontData("Arial")
    portFormat2.FontHeight = 20
    portFormat2.FontItalic = NullableBool.[False]
    portFormat2.FontUnderline = TextUnderlineType.None
    portFormat2.FontBold = NullableBool.[True]
    portion1.Text = "This is the blank slide with white background inserted at the head of the PPT. And then two textboxes without fill and without border line will be added to this blank slide,and then the fontname of the textbox1 is set to Arial, its fontsize is set to 20, its fontcolor is set to yellow, its fontbold is true. The position of textbox1 is set to (20,50) and the size of textbox1 is set to (600,200)"
    portion2.Text = "This is the  added textbox2, and it has no fill and no border line. And fontname of the textbox2 is set to Calibri, its fontsize is set to 14, its fontcolor is set to yellow, its fontbold is true. The position of textbox2 is (20,500) and the size of textbox1 is (600,300)"
    Dim portion3 As Portion = New Portion(CType(portion2, Portion))
    portion3.Text = "The size of the inserted backpicture is the same as the pagesize, and the position of the backpicture is (0,0), and the backpicture is behind the texts"
    Dim para3 As Paragraph = New Paragraph(CType(paragraph2, Paragraph))
    pres.Save(path & "Savedpres.ppt", Aspose.Slides.Export.SaveFormat.Ppt)
End Sub


Thank you very much!
It is what I need!

In addition, How to do it if the backpic will be inserted to each slide?
And I found a bug that is an exception will thrown if return char will be set to portion1.Text.



Can you please share source code in which you are facing exception so that we may further investigate.


the source code like this:
portion1.Text = “This is the blank slide with white background inserted!”
on error resume next
portion1.Text =portion1.Text & vbCrLf & “This is the New title page slide” 'this will throw an exception

on error resume next
portion1.Text =MultilineTextbox1 .text 'this will throw an exception



Unfortunately, we have not been able to understand the issue or requirement in your end. If it’s an issue, can you please provide the details of issue in terms of working sample example. If it’s a requirement in your end, please share complete elaboration.


My another question is that how to place the inserted backpic behind the text?


I may work it out. I place the backpic into the masterslide so that the pic is behind texts.