+ Reply to Thread
Results 1 to 4 of 4

Thread: Macro Copy/Paste Cells into Powerpoint in HTML

  1. #1
    Registered User
    Join Date
    06-28-2011
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    3

    Macro Copy/Paste Cells into Powerpoint in HTML

    Hi every one,

    First, I'm French so please be kind with my english... It makes now 3 days I am trying to copy/paste cells from Excel to PowerPoint. It works very well when I paste as a picture format (EnhancedMetafile) but I can't manage to paste the cells in HTML format (table I can modify into PPT : what I need !!!)...

    I found I had to first create the tab in ppt and paste each cells in it.

    I tried so the following code but "error 424"

    Would you please try to indicate me where is the rub ?
    FYI : the macro has to set up a NEW pptPresentation

    There is maybe another solution (I also tried a Pastespecial HTML but it doesn't work)

    Thank you very much for your kind interset and the time you will allow...

    Sub copietab()
    Dim PptApp As PowerPoint.Application
    Dim PptDoc As PowerPoint.Presentation
    Dim Diapo As PowerPoint.Slide
    Dim pptTempTable As PowerPoint.Table
    Dim Sh As PowerPoint.Shape
    Dim Cs1 As ColorScheme
    Dim NbShpe As Integer
    Dim rngCopy As Range
    Dim lngRow As Long
    Dim lngCol As Long
    
    Set PptApp = CreateObject("Powerpoint.Application")
    Set PptDoc = PptApp.Presentations.Add
    
    With PptDoc
    
    .Slides.Add Index:=1, Layout:=ppLayoutBlank
    
    Set rngCopy = ThisWorkbook.Worksheets("graphiques").Range("B6:K40")
    
    With Diapo
    With PptDoc.Slides(1).Shapes.AddTable(rngCopy.Rows.Count, rngCopy.Columns.Count, 2, 120, 715, -1)
    
    For lngRow = 1 To rngCopy.Rows.Count
    For lngCol = 1 To rngCopy.Columns.Count
    
    rngCopy.Cells(lngRow, lngCol).Copy.Table.Cell(lngRow, lngCol).Shape.TextFrame.TextRange.Characters.Paste
    ' Object needed
    
    Next
    Next
    
    End With
    End With
    End With
    PptDoc.SaveAs Filename:=ThisWorkbook.Path & "\" & "Restitution.ppt"
    'ferme la presentation
    PptDoc.Close
    'ferme powerpoint
    PptApp.Quit
     
    MsgBox "Exportation de la restitution réussie"
    End Sub
    Last edited by Bouternal; 06-29-2011 at 05:27 AM.

  2. #2
    Registered User
    Join Date
    06-28-2011
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Macro Copy/Paste Cells into Powerpoint in HTML

    Bump no response

  3. #3
    Registered User
    Join Date
    06-28-2011
    Location
    France
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Macro Copy/Paste Cells into Powerpoint in HTML

    Hi every one,

    I did find the problem. I had to write te code on two lines... I was a bit tired !

    rngCopy.Cells(lngRow, lngCol).Copy
    .Table.Cell(lngRow, lngCol).Shape.TextFrame.TextRange.Characters.Paste
    Problem solved !

  4. #4
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Macro Copy/Paste Cells into Powerpoint in HTML

    or
    Sub snb()
      Sheets(1).Range("B6:K40").Copy
    
      With New PowerPoint.Application
        .Visible = msoTrue
        .Presentations.Add
        .Presentations(1).Slides.Add 1, ppLayoutBlank
        .Presentations(1).Slides(1).Shapes.Paste
      End With
    End Sub
    without a reference to the powerpoint library:
    Sub snb()
      Sheets(1).Range("B6:K40").Copy
    
      With createobject("PowerPoint.Application")
        .Visible = msoTrue
        .Presentations.Add
        .Presentations(1).Slides.Add 1, 12
        .Presentations(1).Slides(1).Shapes.Paste
      End With
    End Sub
    Last edited by snb; 06-29-2011 at 06:24 AM.



+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0