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.
  • 4853

Introduction

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 
String
    customerDataId = xmlPart.Id
    Debug.Print(customerDataId)
 
    
' 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 
    text!</XMLData>"
)
    Debug.Print(xmlPart.XML)
 
    
' Make a copy of the shape:
    shp.Copy()
 
    
' Create a new slide, and paste the shape into the new slide:
    Dim sld2 As Slide
    sld2 = ActivePresentation.Slides.Add(2, ppLayoutBlank)
    sld2.Shapes.Paste()
 
    
' 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

End
 Sub

Steps for creating Application

Step 1 : Start Microsoft PowerPoint 2010 : 

1.jpg

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

2.jpg

Step 3 : Select on VBAProject(Presentation 1) : 
 

3.jpg

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

4.jpg

5.jpg

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

Clipboard02.jpg

Step 6 : Run Application using F8 :

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

Clipboard05.jpg

Step 8 : Output of Application :

318214_152750694858000_1955576252_n.jpg

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.