Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将图表格式excel转换为powerpoint_Excel_Vba_Powerpoint - Fatal编程技术网

将图表格式excel转换为powerpoint

将图表格式excel转换为powerpoint,excel,vba,powerpoint,Excel,Vba,Powerpoint,这是我在windown上的代码,但当我在macos上运行它时newPowerPoint.ActivePresentation.Slides.Add在这里停留了2-3分钟,有时activeSlide.Shapes.PasteSpecial编译错误:找不到方法或数据成员。macos上的excel上没有粘贴Special,所以我将其更改为myslide.Shapes.Paste。选择,但它错误且超时。有人可以帮助我如何将excel从excel转换为powerpoint。感谢雷德 您的代码使用OLE,这

这是我在windown上的代码,但当我在macos上运行它时
newPowerPoint.ActivePresentation.Slides.Add
在这里停留了2-3分钟,有时
activeSlide.Shapes.PasteSpecial
编译错误:找不到方法或数据成员。macos上的excel上没有粘贴Special,所以我将其更改为myslide.Shapes.Paste。选择,但它错误且超时。有人可以帮助我如何将excel从excel转换为powerpoint。感谢雷德


您的代码使用OLE,这是非常缓慢的,在Office for Mac中有相当多的缺陷。我不清楚为什么在使用VBA时,你的帖子标题会提到AppleScript。是的,我使用了VBA,你可以帮助我用VBA将excel转换为powerpoint。当我在窗口中使用此代码时,它会运行,但mac不会:(Mac对象模型的PowerPoint不如Windows版本的PowerPoint完整。有时,您可以使用备用VBA代码解决问题,有时,您可以使用AppleScript解决问题。这些解决方法可能需要数小时的实验才能找到。祝您好运。
    Dim newPowerPoint As PowerPoint.Application
    Dim activeSlide As PowerPoint.Slide
    Dim cht As Excel.ChartObject
 
    On Error Resume Next
    Set newPowerPoint = GetObject(, "PowerPoint.Application")
    On Error GoTo 0
 
    If newPowerPoint Is Nothing Then
        Set newPowerPoint = New PowerPoint.Application
    End If

    If newPowerPoint.Presentations.Count = 0 Then
        newPowerPoint.Presentations.Add
    End If
 
    newPowerPoint.Visible = True

    For Each cht In ActiveSheet.ChartObjects
        newPowerPoint.ActivePresentation.Slides.Add newPowerPoint.ActivePresentation.Slides.Count + 1, ppLayoutText
        newPowerPoint.ActiveWindow.View.GotoSlide newPowerPoint.ActivePresentation.Slides.Count
        Set activeSlide = newPowerPoint.ActivePresentation.Slides(newPowerPoint.ActivePresentation.Slides.Count)
            
        cht.Select
        ActiveChart.ChartArea.Copy
        activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select

        activeSlide.Shapes(1).TextFrame.TextRange.Text = cht.Chart.ChartTitle.Text
        newPowerPoint.ActiveWindow.Selection.ShapeRange.Left = 15
        newPowerPoint.ActiveWindow.Selection.ShapeRange.Top = 125
    
        activeSlide.Shapes(2).Width = 200
        activeSlide.Shapes(2).Left = 505
        
        If InStr(activeSlide.Shapes(1).TextFrame.TextRange.Text, "US") Then
            activeSlide.Shapes(2).TextFrame.TextRange.Text = Range("J7").Value & vbNewLine
            activeSlide.Shapes(2).TextFrame.TextRange.InsertAfter (Range("J8").Value & vbNewLine)
        ElseIf InStr(activeSlide.Shapes(1).TextFrame.TextRange.Text, "Renewable") Then
            activeSlide.Shapes(2).TextFrame.TextRange.Text = Range("J27").Value & vbNewLine
            activeSlide.Shapes(2).TextFrame.TextRange.InsertAfter (Range("J28").Value & vbNewLine)
            activeSlide.Shapes(2).TextFrame.TextRange.InsertAfter (Range("J29").Value & vbNewLine)
        End If

        activeSlide.Shapes(2).TextFrame.TextRange.Font.Size = 16

    Next
 
AppActivate ("PowerPoint")
Set activeSlide = Nothing
Set newPowerPoint = Nothing