Excel VBA Не могу открыть PPTX - PullRequest
0 голосов
/ 16 марта 2020

Я пытаюсь открыть существующий PPTX из VBA. Это мой код:

*Sub Range_to_Existing_Powerpoint()


Dim fd As FileDialog
Dim sFilename As String


Dim rng As Range
Dim PowerPointApp As PowerPoint.Application
Dim myPresentation As PowerPoint.Presentation
Dim mySlide As Object
Dim myShape As Object


Set rng = ThisWorkbook.ActiveSheet.Range("A1:AC54")
Set PowerPointApp = CreateObject("PowerPoint.Application")
Set fd = Application.FileDialog(msoFileDialogFilePicker)


  With fd
    .Title = "Select file for Export"
    .Filters.Clear
    '.Filters.Add "Excel Files", "*.xls, *.xlsx"
    '.InitialFileName = Environ("USERPROFILE") & "\Desktop\"
    .AllowMultiSelect = False
    If .Show = True Then
    sFilename = .SelectedItems(1)
    Else
        Exit Sub
    End If
  End With
  'do whatever with sFilename


Set myPresentation = PowerPointApp.Presentations.Open(sFilename)
Set mySlide = myPresentation.Slides.Add(1, 11)


rng.Copy


mySlide.Shapes.PasteSpecial DataType:=2  '2 = ppPasteBitmap
Set myShape = mySlide.Shapes(mySlide.Shapes.Count)


PowerPointApp.Visible = True
PowerPointApp.Activate
Application.ScreenUpdating = False

End Sub*

Прекрасно открывается на ноутбуке коллег. То же программное обеспечение, тот же ноутбук. Но я получаю следующую ошибку:

«Ошибка времени выполнения« 429 »: активный компонент X не может создать объект»

Я использую Windows 10 и Microsoft Office 365 Pro Plus 64 bit .

Кто-нибудь может посоветовать, пожалуйста?

Спасибо CSuen

...