VBA在PowerPoint表中选择特定单元格

时间:2017-11-15 18:32:40

标签: vba excel-vba powerpoint excel

如何在PowerPoint表格中选择特定单元格?

我需要将PowerPoint表格(包括我的Excel格式)粘贴到特定单元格中。

代码位于Excel!

具体来说,这是您选择特定单元格的方式!

    PPSlide.Shapes("Table 4").Table.Rows(2).Cells.Item(1).Select

这是一篇信息性帖子,我暂时无法弄清楚如何做到这一点,所以我想我会添加.t

Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide

Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
Dim sht as Worksheet
Set sht = ThisWorkbook.Sheets("Local Channels National View")

   ''''''''COPY TEMPLATE SLIDE''''''''
    ''duplicate template slide, move to end of presentation
    Set slideR = PPPres.Slides(3).Duplicate
    slideR.MoveTo (PPPres.Slides.Count)
    Set PPSlide = PPPres.Slides(PPPres.Slides.Count)




    sht.Range("B10:F14").Copy

    ''''select rows 2, column 1 cell
    PPSlide.Shapes("Table 4").Table.Rows(2).Cells.Item(1).Select

    '''paste
    PPApp.CommandBars.ExecuteMso ("Paste")

资源: CellRange对象 - 单元格,行或列的集合 https://msdn.microsoft.com/en-us/VBA/PowerPoint-VBA/articles/cellrange-object-powerpoint

细胞对象 https://msdn.microsoft.com/en-us/vba/powerpoint-vba/articles/cell-object-powerpoint

2 个答案:

答案 0 :(得分:1)

这是您选择特定单元格的方式:

PPSlide.Shapes("Table 4").Table.Rows(2).Cells.Item(1).Select

答案 1 :(得分:0)

这是使用行和列属性选择单个单元格的正确方法:

PPSlide.Shapes("Table 4").Table.Cell(Row:=2,Column:=1).Select