VBA代码转换(或复制)文件夹中的Excel文件到相应的PowerPoint演示文稿

我是相当新的Excel,我试图写一个macros来将多个Excel电子表格转换为多个PowerPoint幻灯片。 到目前为止,我已经find了一种方法来从一个网站的单个Excel表单制作个人幻灯片:

Option Explicit Sub ExcelRangeToPowerPoint() Dim rng As Excel.Range Dim PowerPointApp As PowerPoint.Application Dim myPresentation As PowerPoint.Presentation Dim mySlide As PowerPoint.Slide Dim myShapeRange As PowerPoint.Shape 'Copy Range from Excel Set rng = ThisWorkbook.ActiveSheet.Range("A1:G17") 'Create an Instance of PowerPoint On Error Resume Next 'Is PowerPoint already opened? Set PowerPointApp = GetObject(class:="PowerPoint.Application") 'Clear the error between errors Err.Clear 'If PowerPoint is not already open then open PowerPoint If PowerPointApp Is Nothing Then Set PowerPointApp = CreateObject(class:="PowerPoint.Application") 'Handle if the PowerPoint Application is not found If Err.Number = 429 Then MsgBox "PowerPoint could not be found, aborting." Exit Sub End If On Error GoTo 0 'Make PowerPoint Visible and Active PowerPointApp.Visible = True PowerPointApp.Activate 'Create a New Presentation Set myPresentation = PowerPointApp.Presentations.Add 'Add a slide to the Presentation Set mySlide = myPresentation.Slides.Add(1, ppLayoutTitleOnly) 'Copy Excel Range rng.Copy 'Paste to PowerPoint and position mySlide.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile Set myShapeRange = mySlide.Shapes(mySlide.Shapes.Count) 'Set position: myShapeRange.Left = 150 myShapeRange.Top = 186 'Clear The Clipboard Application.CutCopyMode = False End Sub 

我只是想弄清楚,是否有一个macros,可以循环通过给定的文件夹/目录,并将所有的Excel文件转换为PowerPoint演示文稿?

你懂吗? 它将从单个单元格范围创build一个幻灯片。 如果您的工作簿文件有多个工作表? 如果在每张纸上的范围是不同的呢?

你的代码将需要适应这个。

所以你会写代码

  1. 循环访问文件夹中的每个excel文件
  2. 循环遍历文件中的每个工作表
  3. 将新幻灯片添加到当前工作表的一个PowerPoint文件中
  4. find当前工作表的范围,并将范围添加到幻灯片

你不顾一切地自动化这个? 如果你只需要这样做一次,你可能是最好的手动? 取决于文件的数量以及当然你多久做一次。

回答你的问题,看看这里使用目录来查找文件夹中的文件..但是有更多的代码需要做到这一点!

可能有一个工具可以在网上做到这一点…例如, 在这里我没有起诉,但这是一个共同的需要。