将Excel表复制到PowerPoint(2010)的最佳方法? [英] Best Way to Copy Excel Table into PowerPoint (2010)?
问题描述
我正在尝试将一系列Excel表格转换为PowerPoint,并在Office 2013中成功创建了一个宏,但正在尝试将其转换为Office 2010。
I'm trying to get a series of Excel tables into PowerPoint and successfully created a macro for this in Office 2013, but am trying to adapt it to Office 2010.
问题是将表格粘贴到PowerPoint时,Office 2010似乎需要一个唯一/不同的代码。
The issue is when pasting the table to PowerPoint, Office 2010 seems to require a unique/different code.
最初我有:
'Copying Tables to PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
For i = 0 To Table3
Sheets("Charts").Range(ChartStart, ChartEnd).Offset(i * Row2, 0).Copy
Set PPSlide = PPPres.Slides(1)
Set PPShape = PPSlide.Shapes.Paste
PPShape.Name = "Table" & i
但是自从被告知2010年版本的修复是使用.PasteSpecial所以我有: / p>
But have since been informed a fix for 2010 versions is to use .PasteSpecial so I have:
'Copying Tables to PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
For i = 0 To Table3
Sheets("Charts").Range(ChartStart, ChartEnd).Offset(i * Row2, 0).Copy
Set PPSlide = PPPres.Slides(1)
Set PPShape = PPSlide.Shapes.PasteSpecial(dataType:=10)
PPShape.Name = "Table" & i
事情正在使用DataType:= 10将图表放入PowerPoint中,格式不正确,用于我的目的。我需要使用ppPasteHTML将表格作为表格使用PowerPoint,但是当我尝试将其输入到PasteSpecial函数中时,我会收到一个错误代码,表示剪贴板为空。
The thing is using DataType:=10 puts the chart into PowerPoint in an incorrect format for my purposes. I need to get the table into PowerPoint as a table using ppPasteHTML, however, when I try to enter this into the PasteSpecial function I get an error code saying the Clip board is empty.
有没有人知道ppPasteHTML是否具有与PasteSpecial中的DataType选项相当的数值?还有另一种方法可以将Excel表格作为Office 2010的表格取得PowerPoint?
Does anyone know if "ppPasteHTML' has a numeric equivalent for the DataType option in PasteSpecial? Or another way to get an Excel table into PowerPoint as a table for Office 2010?
谢谢!
推荐答案
应该这样做:
只需确保您正在Excel中加载PowerPoint库。
Just make sure you are loading the PowerPoint Library in Excel.
工具 - >参考 - >Microsoft PowerPoint nn.n对象库
Tools->References->"Microsoft PowerPoint nn.n Object Library"
另外我假设 Table3
, ChartStart
, ChartEnd
&
Row2
设置值
Dim pptApp As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Dim pptSlide As PowerPoint.Slide
'Open PowerPoint and create a new presentation.
Set pptApp = New PowerPoint.Application
Set pptPres = pptApp.Presentations.Add
Set pptSlide = pptPres.Slides.Add(1, ppLayoutBlank)
For i = 0 To Table3
Set objRange = Worksheets("Charts").Range(ChartStart, ChartEnd).Offset(i * Row2, 0)
objRange.Copy
pptSlide.Shapes.PasteSpecial DataType:=ppPasteHTML, Link:=msoFalse
Next i
For j = 1 To pptSlide.Shapes.Count
With pptSlide.Shapes(j)
.Name = "Table" & j
End With
Next j
Set pptSlide = Nothing
Set pptPres = Nothing
Set pptApp = Nothing
这篇关于将Excel表复制到PowerPoint(2010)的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!