Results 1 to 1 of 1

Export from Excel to powerpoint using VBA

Threaded View

  1. #1
    Registered User
    Join Date
    10-31-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    8

    Export from Excel to powerpoint using VBA

    Dear All,
    I am new to VBA programmining and for the first time trying to export excel data to powerpoint. The code I have compiled from sources on the web is as follows but does not work.

    Sub CreateSlides()
    'Step 1: Declare your variables
      Dim PP As PowerPoint.Application
      Dim oSl As PowerPoint.Slide
        Dim oSh As PowerPoint.Shape
    
      'Dim PPPres As PowerPoint.Presentation
      'Dim PPSlide As PowerPoint.Slide
      'Dim SlideTitle As String
      
    'Step 2: Open PowerPoint and create new presentation
      Set PP = New PowerPoint.Application
      Set PPPres = PP.Presentations.Add
      PP.Visible = True
      ActivePresentation.Slides(1).Copy
        Set oSl = ActivePresentation.Slides.Paste(ActivePresentation.Slides.Count + 1)
    'Open the Excel workbook. Change the filename here.
    Dim OWB As New Excel.Workbook
    Set OWB = Excel.Application.Workbooks.Open("C:\users\CABS\desktop\WeeklyReturn.xlsm")
      
    'Grab the first Worksheet in the Workbook
    Dim WS As Excel.Worksheet
    Dim sCurrentText As String
    Dim Slidenum As Integer
    Set WS = OWB.Worksheets("Master")
    Dim i As Long
    'Loop through each used row in Column A
    For i = 1 To WS.Range("A65536").End(xlUp).Row
    
        'Copy the first slide and paste at the end of the presentation
        ActivePresentation.Slides(1).Copy
        Set oSl = ActivePresentation.Slides.Paste(ActivePresentation.Slides.Count + 1)
        sCurrentText = WS.Cells(i, 1).Value
        '------------
        'Slidenum = 1
        oSl.Select
        Set oSh = oSl.Shapes("Table1")
    
        Sheets("Sheet1").Activate
        oPPTShape.Table.Cell(i, 1).Shape.TextFrame.TextRange.Text = sCurrentText
        'oPPTShape.Table.Cell(1, 2).Shape.TextFrame.TextRange.Text = Cells(1, 2).Text
        'oPPTShape.Table.Cell(1, 3).Shape.TextFrame.TextRange.Text = Cells(1, 3).Text
        'oPPTShape.Table.Cell(2, 1).Shape.TextFrame.TextRange.Text = Cells(2, 1).Text
        'oPPTShape.Table.Cell(2, 2).Shape.TextFrame.TextRange.Text = Cells(2, 2).Text
        'oPPTShape.Table.Cell(2, 3).Shape.TextFrame.TextRange.Text = Cells(2, 3).Text
        '--------------------------
        
        
        ' find each shape with "@COL1@" in text, replace it with value from worksheet
     '   For Each oSh In oSl.Shapes
          ' Make sure the shape can hold text and if is, that it IS holding text
     '     If oSh.HasTextFrame Then
     '       If oSh.TextFrame.HasText Then
     '         ' it's got text, do the replace
             ' With oSh.TextFrame.TextRange
                '.Replace "@COL1@", sCurrentText
              'End With
     '       End If
     '     End If
      '  Next
    Next
    End Sub
    Request help
    Last edited by mayoorsubbu; 10-31-2015 at 10:33 AM. Reason: As per Forum Rules, please use code tags…Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Excel macro to export Graphs to Powerpoint
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-10-2013, 02:16 AM
  2. Trying to export results from a PowerPoint quiz to Excel
    By DPWM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-09-2013, 01:54 PM
  3. [SOLVED] I need to export charts on individual pages from Excel to Powerpoint?
    By ssands in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-24-2012, 02:48 PM
  4. VBA Code to export Excel to OVERWRITE an EXISTING PowerPoint
    By rick_tiger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-06-2012, 04:49 AM
  5. Export data from Excel to PowerPoint
    By nalfin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-01-2009, 09:46 AM
  6. Excel to Powerpoint export
    By webbug08 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-05-2009, 09:41 AM
  7. Export Excel data to Word and PowerPoint
    By racudd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-27-2007, 11:30 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1