Guide for VB.NET
Core Document Formats
Additional Features

VB.NET PowerPoint - How to Merge and Split

Combine or Split PPT Document(s) with VB.NET PPT Document Processing SDK

Home > .NET Imaging SDK > VB.NET > PowerPoint: Merge or Split
To get started with DocImage SDK for .NET, you are supposed to read VB.NET Imaging: Get Started first!

Sometimes, when you are going to create a new PowerPoint document, you might want to use the slides from your older PPT files or combine two different PPT documents to a single one. Or on the contrary, you might need to split the current PPT document into two separate presentations. Then, have you considered achieving these targets by using a mature and professional .NET PowerPoint merging and splitting control? If so, here is what you are looking for - RasterEdge VB.NET PPT Document Merger and Splitter SDK.
Related .net document control helps: word document viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
mvc pdf editor: ASP.NET MVC PDF Viewer & Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC dicom viewer: ASP.NET Dicom Document Viewer Control: view, annotate dicom imaging files online in ASP.NET excel web viewer: ASP.NET Excel Viewer in C# Control (MVC & WebForms): view Office Excel document in web browser. document viewer control: EdgeDoc:ASP.NET Document Viewer C# Control: Open, view, annotate, redact, convert documents online in C#, VB.NET, AS... pdf editor control: EdgePDF: ASP.NET PDF Editor Web Control: Online view, annotate, redact, edit, process, convert PDF documents image viewer zoom: ASP.NET Image Viewer Control(MVC & WebForms): view, annotate, redact, convert image files in html, JQuery
Let's see what will be provided on this PPT document merging and splitting tutorial:
  • Simple introduction of VB.NET PPT document merging and the comprehensive VB demo APIs and sample codes on combining PPT documents
  • VB.NET PowerPoint document splitting overview and the complete sample methods and codes on how to split a certain PPT document into two or more sub-files
PowerPoint Merging
By using this PPT document merging control in VB program, we can create a new PPT document by combining a list of PPT files into a big one directly or build single PPT presentation out of multiple Microsoft PowerPoint documents when we want to add slides from several existing presentations to the new presentation that you are creating.

See Sample Methods

Following list of APIs and methods in VB.NET class are for combining and merging two or more target PowerPoint documents into one and save it in the route of native file or memory steam. Besides, users are free to name or rename the new PPT file with simple VB.NET code.
Note: PPTXDocument is an abstract concept of the loaded PowerPoint file in VB.NET project. It contains all the PPT document viewing and later handling functions. And its individual slide is with the virtual presentation of PPTXPage.
Private Sub Combine(source As List(Of BaseDocument), destn As Stream) Implements PPTXDocument.Combine
End Sub
Private Sub Combine(source As List(Of BaseDocument), destn As [String]) Implements PPTXDocument.Combine
End Sub
Private Sub Combine(source As List(Of [String]), destn As Stream) Implements PPTXDocument.Combine
End Sub
Private Sub Combine(source As List(Of [String]), destn As [String]) Implements PPTXDocument.Combine
End Sub

Code on Combining Slides/Pages out of Multiple PPT Files

There are sometime when we want to combine and merge PPT slides from two, four or more PPT presentations to form a single new document. Then the best way to reach this target is to use a PPT slides/pages combiner, such as our VB.NET PPT slides combining control.
Following VB example code is for combining available PPT slides from two documents, and if you need to merge slides from more than two files, you can call the above combing methods to write a circulate program.
''' <summary>
''' Two PowerPoint files are available, and we want combine some pages of document 1 and some pages of document 2 to form a new PPT document
''' </summary>
''' <returns></returns>
Public Sub ExtractPagesToFormNewDocument(filePath1 As [String], filePath2 As [String], pageList1 As List(Of Integer), pageList2 As List(Of Integer), destnPath As [String])
' two temporary string to store the extracted documents file paths
Dim tmpFilePath1 As [String] = "c:\tmpFile1"
Dim tmpFilePath2 As [String] = "c:\tmpFile2"

PPTXDocument.ExtractPagesFromDocument(filePath1, pageList1, tmpFilePath1)
PPTXDocument.ExtractPagesFromDocument(filePath2, pageList2, tmpFilePath2)

Dim docPathList As List(Of [String]) = New List(Of String)()


PPTXDocument.Combine(docPathList, destnPath)

End Sub

Save Merged PPT Document to File

With the support of powerful and flexible PowerPoint documents merging and saving methods, users can use following demo VB.NET code to combine PowerPoint files and save the merged one into local file with a user-defined storage path.
''' <summary>
''' Combine a list of documents into a single one and save it to file
''' </summary>
''' <param name="s"></param>
''' <param name="docList"></param>
Public Sub CombineDocumentAndSaveItToFile(filePath As [String], docList As List(Of [String]))

PPTXDocument.Combine(docList, filePath)

End Sub

Store Combined PPT File to Stream

By using Visual Basic .NET sample code below to combine a list of PowerPoint documents and save the created new file in the form of memory stream.
''' <summary>
''' Combine a list of documents under the folder into a single one and save it to stream
''' </summary>
''' <param name="s"></param>
''' <param name="docList"></param>
Public Sub CombineDocumentsToStream(combinedPath As [String])
Dim dirs As String() = Directory.GetFiles("D:\FontFile2\", "*.pptx")

Dim docList As List(Of [String]) = New List(Of String)()

For Each doc As [String] In dirs

PPTXDocument.Combine(docList, combinedPath)

End Sub
PowerPoint Splitting
As we have solved the problem of combining PowerPoint documents, it's time to consider PowerPoint document splitting in VB.NET. Just like we need to combine PPT files, sometimes, we also want to separate a complete PPT document into two or more independent sub-files. Then, here comes the VB.NET PPT document splitter in handy. Please check following PowerPoint document splitting and separating methods and APIs in VB.NET programming language.

Splitting APIs

Private Sub SplitDocument(source As Stream, index As Integer, destns As List(Of [String])) Implements PPTXDocument.SplitDocument
End Sub
Private Sub SplitDocument(source As [String], index As Integer, destns As List(Of [String])) Implements PPTXDocument.SplitDocument
End Sub
Private Sub SplitDocument(source As Stream, index As Integer, destns As List(Of Stream)) Implements PPTXDocument.SplitDocument
End Sub
Private Sub SplitDocument(index As Integer, source As [String], destns As List(Of Stream)) Implements PPTXDocument.SplitDocument
End Sub
And here is a crucial instruction: a method called "int Index" among the list of APIs is the key to PPT document splitting. If you input a page number "3", the loaded PPT document will be divided into two separate sub-PPT files from the fourth slide, which means that one of the split PPT document will contain slides/pages 1-4, and the other includes the left.

Splitting Code

Please refer to following sample code in VB.NET to finish PowerPoint document splitting with extremely high-speed.
''' <summary>
''' Split a document into 2 sub-ocuments
''' </summary>
''' <param name="originalDocument"></param>
''' <param name="pageIdx"></param>
Public Sub splitPPTXDocument(sourceFilePath As [String], pageIdx As Integer, destnsPath As List(Of [String]))

PPTXDocument.SplitDocument(sourceFilePath, pageIdx, destnsPath)

End Sub
Note: If you want to see more PDF processing functions in VB.NET, please follow the link. If you are C# end users or developers, you may go to C#.NET PPT merging and splitting guide.

Recommend this to Google+ is professional provider of ASP.NET MVC Document Viewer, ASP.NET PDF Viewer, MVC PDF Viewer document, content and imaging solutions, available for ASP.NET AJAX, Silverlight, Windows Forms as well as WPF. We are dedicated to provide powerful & profession imaging controls, PDF document, image to pdf files and components for capturing, viewing, processing, converting, compressing and stroing images, documents and more.

©2000-2017 Raster