如何插入一个图像从一个excel单元格到powerpoint中使用css?

oo7oh9g9  于 2023-11-20  发布在  其他
关注(0)|答案(1)|浏览(143)

Slides output with 1 text +1 picture, 2 text + 1 picture我想再引入3个文本占位符,总共4个。我的图片在excel表的第4列。但是当我引入第2个文本占位符时,图片不在图片占位符中。所以,我修改了代码,

  1. Sld.Shapes.Placeholders(1).TextFrame.TextRange.Text = DataRow.Cells(1, 1)
  2. Sld.Shapes.Placeholders(2).TextFrame.TextRange.Text = DataRow.Cells(1, 2)
  3. Sld.Shapes.Placeholders(3).TextFrame.TextRange.Text = DataRow.Cells(1, 3)
  4. sCell = DataRow.Cells(1, 4).Address
  5. ' Check if there is a shp in Column 3
  6. If objDic.exists(sCell) Then
  7. objDic(sCell).Copy
  8. Sld.Shapes.Placeholders(4).Select
  9. Sld.Shapes.PasteSpecial DataType:=ppPasteMetafilePicture
  10. End If

字符串
即使有4个文本占位符,输出也是一样的。图片不在PicturePlaceholder中。尝试了几次。无法弄清楚我哪里出错了?我可以得到帮助吗?
The first 2 rows are with images in textbox and the next two are imprted to cell as image without textbox我有一个三列的Excel表A,B和C。第一个两列有文本,第三列C有图像嵌入文本框。我有1000行。我想将这些列导出到PPT幻灯片。我在PPT的slidemaster中得到了三个占位符。前两个占位符用于插入文本,第三个用于插入图像。我已经写了一个vba宏,导出第一个两列的文本从Excel到PPT.工作正常.我想知道如何插入图像从Excel工作表的第三列(图像是在文本框)在第三个占位符意味着图像.该程序如下.

  1. Sub LoopRowsSelected2Choices()
  2. Dim DataRange As Range
  3. Dim DataRow As Range
  4. Dim AppPPT As PowerPoint.Application
  5. Dim Prs As PowerPoint.Presentation
  6. Dim Sld As PowerPoint.Slide
  7. Set AppPPT = GetObject(, "PowerPoint.Application")
  8. Set Pres = AppPPT.ActivePresentation
  9. Set DataRange = Selection
  10. For Each DataRow In DataRange.Rows
  11. Set Sld = Pres.Slides.AddSlide(Pres.Slides.Count + 1, Pres.SlideMaster.CustomLayouts(2))
  12. Sld.Shapes.Placeholders(1).TextFrame.TextRange.Text = DataRow.Cells(1, 1)
  13. Sld.Shapes.Placeholders(2).TextFrame.TextRange.Text = DataRow.Cells(1, 2)
  14. Next DataRow
  15. End Sub


前两列的占位符工作正常。我在第三列的图像,并希望在PPT中的第三个占位符isert意味着图片。任何解决方案?提前感谢
我尝试并成功地插入了文本,但没有插入图像。

2cmtqfgy

2cmtqfgy1#

在单元格上添加图片是一个很好的方法,用JavaScript代码操作起来更容易。

  1. Option Explicit
  2. Sub LoopRows()
  3. Dim DataRange As Range
  4. Dim DataRow As Range
  5. Dim AppPPT As PowerPoint.Application
  6. Dim Pres As PowerPoint.Presentation
  7. Dim Sld As PowerPoint.Slide
  8. Dim objDic As Object, Shp As Shape, i As Integer
  9. Dim sCell As String
  10. Set AppPPT = GetObject(, "PowerPoint.Application")
  11. Set Pres = AppPPT.ActivePresentation
  12. ' Verify the Selection is a Range object
  13. If TypeName(Selection) = "Range" Then
  14. ' Load Dict, Key = TopLeftCell.Address, Value = Shp object
  15. Set objDic = CreateObject("scripting.dictionary")
  16. For i = 1 To ActiveSheet.Shapes.Count
  17. Set Shp = ActiveSheet.Shapes(i)
  18. If Not Application.Intersect(Shp.TopLeftCell, Selection) Is Nothing Then
  19. Set objDic(Shp.TopLeftCell.Address) = Shp
  20. End If
  21. Next
  22. Set DataRange = Selection
  23. ' Loop through data row
  24. For Each DataRow In DataRange.Rows
  25. Set Sld = Pres.Slides.AddSlide(Pres.Slides.Count + 1, Pres.SlideMaster.CustomLayouts(2))
  26. Sld.Select
  27. Sld.Shapes.Placeholders(1).TextFrame.TextRange.Text = DataRow.Cells(1, 1)
  28. Sld.Shapes.Placeholders(2).TextFrame.TextRange.Text = DataRow.Cells(1, 2)
  29. sCell = DataRow.Cells(1, 3).Address
  30. ' Check if there is a shp in Column 3
  31. If objDic.exists(sCell) Then
  32. objDic(sCell).Copy
  33. Sld.Shapes.Placeholders(3).Select
  34. Sld.Shapes.PasteSpecial DataType:=ppPasteMetafilePicture
  35. End If
  36. Next DataRow
  37. End If
  38. End Sub

字符串

  • Microsoft文档:*

Shapes.PasteSpecial method (PowerPoint)


的数据

展开查看全部

相关问题