在PPT文本框中复制和粘贴单元格

发布于 2025-02-11 02:55:13 字数 1287 浏览 1 评论 0原文

我想知道是否有人可以帮助我编写特定范围内的代码(例如A2-A5),它在PPT上的文本框中复制并粘贴了第一个单元格A2,然后将其复制到A3,并将其复制并粘贴到PPT中的另一个TXTBOX,依此类推,直到最后一行。

我写了此代码,但这仅在PPT上的一个文本框中复制整个范围A2-A5: Sub OpenPoints()

Dim PPT As PowerPoint.Application
Dim pres As PowerPoint.Presentation
Dim sl As PowerPoint.Slide
Dim sh As PowerPoint.Shape
Dim sh1 As PowerPoint.Shape
Dim r As Range
Dim filterRange As Range
Dim copyRange As Range
Dim lastRow As Long


'Open Powerpoint

Set PPT = New PowerPoint.Application
Set pres = PPT.Presentations.Open(ThisWorkbook.Path & "\Edenred_ProjectStatus_Saxo.pptx")

'Insert open points description
Set sl = pres.Slides(1)
Set sh1 = sl.Shapes("Rectangle 40")



'Filtra per "Y"

ThisWorkbook.Sheets("Action&Open_Point").Range("H1").AutoFilter field:=1, Criteria1:="Y"

'Individuazione ultima riga
lastRow = ThisWorkbook.Sheets("Action&Open_Point").Range("D" & 
ThisWorkbook.Sheets("Action&Open_Point").Rows.Count).End(xlUp).Row

'Copia colonna descrizione
Set copyRange = ThisWorkbook.Sheets("Action&Open_Point").Range("D2:D" & lastRow)
ActiveWorkbook.Worksheets("Action&Open_Point").UsedRange.Font.Underline = False
copyRange.SpecialCells(xlCellTypeVisible).Copy


sh1.TextFrame2.TextRange.PasteSpecial msoClipboardFormatRTF

预先感谢您的帮助!

I was wondering if someone could help me writing a code that, in a specific range (e.g A2-A5), it copies and pastes the first cell A2 in a textbox on ppt, then it goes to A3 and it copies and pastes it into another txtbox in ppt and so on until the last row.

I have this code written but this copies the whole range A2-A5 in one textbox only on ppt:
Sub OpenPoints()

Dim PPT As PowerPoint.Application
Dim pres As PowerPoint.Presentation
Dim sl As PowerPoint.Slide
Dim sh As PowerPoint.Shape
Dim sh1 As PowerPoint.Shape
Dim r As Range
Dim filterRange As Range
Dim copyRange As Range
Dim lastRow As Long


'Open Powerpoint

Set PPT = New PowerPoint.Application
Set pres = PPT.Presentations.Open(ThisWorkbook.Path & "\Edenred_ProjectStatus_Saxo.pptx")

'Insert open points description
Set sl = pres.Slides(1)
Set sh1 = sl.Shapes("Rectangle 40")



'Filtra per "Y"

ThisWorkbook.Sheets("Action&Open_Point").Range("H1").AutoFilter field:=1, Criteria1:="Y"

'Individuazione ultima riga
lastRow = ThisWorkbook.Sheets("Action&Open_Point").Range("D" & 
ThisWorkbook.Sheets("Action&Open_Point").Rows.Count).End(xlUp).Row

'Copia colonna descrizione
Set copyRange = ThisWorkbook.Sheets("Action&Open_Point").Range("D2:D" & lastRow)
ActiveWorkbook.Worksheets("Action&Open_Point").UsedRange.Font.Underline = False
copyRange.SpecialCells(xlCellTypeVisible).Copy


sh1.TextFrame2.TextRange.PasteSpecial msoClipboardFormatRTF

Thank you in advance for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文