Custom XML Data in PowerPoint 2010 Using PPT.CustomerDataDemo in VB.NET

In this article I am going to explain about how to use custom XML data in a Microsoft PowerPoint 2010 presentation.
  • 5130


In this article I am going to explain about how to use custom XML data in a Microsoft PowerPoint 2010 presentation. For this we use PPT.CustomerDataDemo in Microsoft PowerPoint 2010. Using PPT.TableProperties we can use custom XML Data in a Microsoft PowerPoint 2010 presentation.

Microsoft Office 2010 offer some powerful tools, using this tools you can create application. Using Microsoft Visual Basic for Applications (VBA) you can create your own application according to your need. These application can performer some specific task.

For creating application we can use

  • VBA host of Excel 2010
  • VBA host of PowerPoint 2010
  • VBA host of Word 2010n

NOTE : OneNote 2010 is not a VBA host.

Code that we use in this application are given below

Sub WorkWithCustomerData() 

    Dim shp As Shape
    Dim sld As Slide
    sld = ActivePresentation.Slides(1)
    shp = sld.Shapes.AddShape(msoShape7pointStar, 10, 10, 200, 200)
' Add a CustomXMLPart as the CustomerData property of the shape.
    Dim xmlPart As CustomXMLPart
    xmlPart = shp.CustomerData.Add
' Print out the unique ID:
    Dim customerDataId As 
    customerDataId = xmlPart.Id
' Put some well-formed XML into the part. You might get this XML from a
' text file, from a database, or from a Web Service:

    xmlPart.LoadXML("<XMLData TextToDisplay='Title' Date='5/15/2012' Author='Lucy'>Here's some 
' Make a copy of the shape:
' Create a new slide, and paste the shape into the new slide:
    Dim sld2 As Slide
    sld2 = ActivePresentation.Slides.Add(2, ppLayoutBlank)
' Retrieve a reference to the new shape:
    Dim shp2 As Shape
    shp2 = sld2.Shapes(1)
    Dim cxp As CustomXMLPart
    For Each cxp In shp2.CustomerData
        customerDataId = cxp.Id
        xmlPart = shp2.CustomerData.Item(customerDataId)

' Verify that the custom XML content in the CustomerData property
' has been propogated with the copied shape:
        Debug.Print("Newly copied part: " & xmlPart.XML)

    Next cxp


Steps for creating Application

Step 1 : Start Microsoft PowerPoint 2010 : 


Step 2 : Using Alt + F11 Key Start Visual Basic for Applications (VBA) Window :


Step 3 : Select on VBAProject(Presentation 1) : 


Step 4 : Right Click On VBAProject(Presentation 1) ==> Goto Insert==> Goto Module & click on Module:



Step 5 : Write Code in Visual Basic for Applications (VBA) Window :


Step 6 : Run Application using F8 :

Step 7 : Macros window will open, Select Macros name and click on Run Button :


Step 8 : Output of Application :



More Articles

© 2020 DotNetHeaven. All rights reserved.