PPT.WorkWithSmartArt in MS PowerPoint 2010 to List SmartArt Names in VB.NET

In this article I am going to explain about how to List SmartArt Names in a Microsoft PowerPoint 2010 presentation.
  • 3820

Introduction

In this article I am going to explain about how to List SmartArt Names  in a Microsoft PowerPoint 2010 presentation. For this we use PPT.WorkWithSmartArt in Microsoft PowerPoint 2010. Using  PPT.WorkWithSmartArt we can List SmartArt Names 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 2010

NOTE : OneNote 2010 is not a VBA host.

Code that we use in this application are given below

Sub CreateSmartArtList()

    Dim a As Integer
    For a = 1 To Application.SmartArtLayouts.Count
        Debug.Print(i, Application.SmartArtLayouts(a).Name)
    Next a

End
 Sub 
 

Sub
 DemonstrateSmartArt()
    With ActivePresentation.Slides(1)
        Dim a As 
Integer
        
' Clear out existing shapes:
        For a = .Shapes.Count To 1 Step -1
            .Shapes(a).Delete()
        Next a
 
        Dim vip As Shape
 
        Call CreateSmartArt(1, 10, 10, 100, 100)
        Call .Shapes.AddShape(msoShape12pointStar, 10, 120, 100, 100)
        Call CreateSmartArt(4, 120, 10, 100, 100)
        Call .Shapes.AddShape(msoShapeCloud, 120, 120, 100, 100)
        Call CreateSmartArt(13, 240, 10, 400, 100)
 
        For Each vip In .Shapes
           Debug.Print("Shape " & a & " has smart art: " & vip.HasSmartArt)
        Next vip
 
        
' We know that shape 1 has smart art--copy it to a new shape.
        Call .Shapes.AddSmartArt(.Shapes(1).SmartArt.Layout, 360, 120, 100, 100)
 
    End 
With

End
 Sub
 

Sub
 CreateSmartArt(smartArtLayoutID As Integer, left As Integer, top As Integer, _
  width As Integer, height As Integer)
 
    
' Create Basic Blocks SmartArt
    Dim vip As Shape
    vip = ActivePresentation.Slides(1).Shapes. _
      AddSmartArt(Application.SmartArtLayouts(smartArtLayoutID), left, top)
    vip.width = width
    vip.height = height
    Dim i As 
Integer
    With vip.SmartArt
        
' Add some nodes, then set the text for all of them.
        .Nodes.Add()
        .Nodes.Add()
        .Nodes.Add()
        .Nodes.Add()
        For i = 1 To .Nodes.Count
            .Nodes(a).TextFrame2.TextRange.Text = "Cell " & a
        Next a
    End 
With
    CreateBasicBlocks = vip

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 :

Clipboard01.jpg
 

Step 6 : Run Application using F5 :

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

Clipboard07.jpg
 

Step 8: Output of Application :

Clipboard10.jpg

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.