Exporting An Excel Table From Excel To PowerPoint Using VBA

Поділитися
Вставка
  • Опубліковано 16 жов 2024

КОМЕНТАРІ • 12

  • @donnaprice1485
    @donnaprice1485 5 років тому +2

    Your videos are great and they have been a big help! I was wondering if you have a video on how to open an existing PPT and export a chart or table from Excel to a specific slide using VBA?

    • @SigmaCoding
      @SigmaCoding  5 років тому

      Unfortunately, I don't have a video up at this point. I will probably have one up in the near future. However, I do have some code on GitHub that should help you out: github.com/areed1192/sigma_coding_youtube/blob/master/vba/powerpoint-vba
      This is where I'll be posting all my code going forward, the file you'll be looking for is "Export Excel Objects To Specific Slide.bas"
      Let me know if you run into any issues accessing it, as I only recently uploaded all my code.

  • @Mktvlogs80
    @Mktvlogs80 3 роки тому

    Hi... Thanks for the videos... I have multiple sheets (sheet1, sheet2) and data from sheet1 has to go to slide 1, data from sheet2 and so on... Can you please let me know whether you have created any video for this

  • @BITSTraining
    @BITSTraining 2 роки тому

    Hi there! Great information; thanks! A question on my side (yes, I admit: I'm a novice! ;-)): I get a OLE message in Excel as PowerPoint "don't answer", and it takes sooooooo long for the macro to run completely; any idea or suggestion to improve this? It just seems I can't activate the macro and let my computer do what it's supposed to do ;-/

  • @JS-zb6zh
    @JS-zb6zh 5 років тому

    I have a question how do you copy ws.Range("A1:G2").copy from sheet1 in Excel to PPT in an existing table. I am able to paste one cell at a time but how do you paste a range. For example I am able to paste ws.range("A1").copy to tbl.cell(3,2).shape.textframe.textrange.paste but how do you copy a range from excel to a table range in PPT.

  • @JS-zb6zh
    @JS-zb6zh 5 років тому +1

    great tutorial very well presented. in your video how do you refer to the object list table once in PowerPoint and find and replace the word "Name" to something else to field headings of the object list (excel table)

    • @SigmaCoding
      @SigmaCoding  5 років тому

      If you want to work with an individual cell on a PowerPoint table object it will look something like this:
      Sub ChangeSingleCell()
      'Set the Slide
      Set PPTSlide = ActivePresentation.Slides(1)
      'Set the shape
      Set PPTShape = PPTSlide.Shapes(1)
      'With the row 1 column 1
      With PPTShape.Table.Cell(1, 1)
      'Set the new text
      .Shape.TextFrame.TextRange.Text = "My New Name"
      End With
      End Sub
      This would change the cell row one column one to the value "My New Name." As you can tell it's not as easy as in Excel, but this is how you would approach the problem. Hopefully, this answers your question.

    • @JS-zb6zh
      @JS-zb6zh 5 років тому +1

      @@SigmaCoding Thank you for taking your time to reply. I've tried the code and it works perfectly. I managed to create vba code that looks into a folder for all pptx presentation files then it opens each one and find and replaces specific words on specific slides on specific shapes using do while loop. Now I want to include another procedure to loop through each slide for each shape and place a text box in of the shapes with the word "Pending". I'm not sure how to do with. I have do while loop so I'm guessing i have to combine do while loop with for each loop.

    • @SigmaCoding
      @SigmaCoding  5 років тому

      So here I add a textbox for each shape in the presentation. Keep in mind, you CANNOT USE A FOR EACH LOOP or else we will get an infinite loop. The reason why is that as we add a new shape our Shapes collection then has another shape we have to loop through creating a never-ending cycle of adding shape and then looping through the newly created shape.
      Sub SetTextBox()
      Dim sld As Slide
      Dim shp As Shape
      'Loop through each slide
      For Each sld In ActivePresentation.Slides
      'Get the number of shapes on the slide - VERY IMPORTANT WE DO THIS
      NumLoop = sld.Shapes.Count
      'Loop through each shape using a FOR I LOOP OTHERWISE WE WILL GET AN INFINITE LOOP USING FOR EACH
      For i = 1 To NumLoop
      'Add a text box.
      sld.Shapes.AddTextbox Orientation:=msoTextOrientationHorizontal, _
      Left:=sld.Shapes(i).Left, _
      Top:=sld.Shapes(i).Top, _
      Width:=200, _
      Height:=50
      'Set the properties about our shape.
      With sld.Shapes(sld.Shapes.Count)
      .TextFrame.TextRange.Text = "Pending"
      .TextFrame.TextRange.Font.Name = "Arial"
      .TextFrame.TextRange.Font.Bold = True
      .TextFrame.TextRange.Font.Color = vbRed
      .Rotation = 45
      End With
      Next i
      Next sld
      End Sub

    • @JS-zb6zh
      @JS-zb6zh 5 років тому

      @@SigmaCoding Thanks. But I just realised I did not need to go through every shape. I just needed to insert a text box with the Pending. So I used AddTextbox method but I also need to change the properties like font/size/rotation. so my question is once I've inserted a textbox how do I refer to it to then change its properties. I will be doing this for all the pptx files in my folder. This is for slide 3, 4 and 5 only for all the pptx files in my folder.

    • @SigmaCoding
      @SigmaCoding  5 років тому

      In the code up above, this is the section where you manipulate the shape and it's properties:
      'Set the properties about our shape.
      With sld.Shapes(sld.Shapes.Count)
      .TextFrame.TextRange.Text = "Pending"
      .TextFrame.TextRange.Font.Name = "Arial"
      .TextFrame.TextRange.Font.Bold = True
      .TextFrame.TextRange.Font.Color = vbRed
      .Rotation = 45
      End With