VBA Macros Excel Открытие PowerPoint: не удалось открыть метод презентации объектов - PullRequest
0 голосов
/ 05 сентября 2018

Я работаю над файлом Excel, который включает в себя открытие PowerPoint в качестве шага. Однако, когда я запускаю его, он выдает сообщение об ошибке «Не удалось открыть метод представления объекта». Когда я нажимаю «Отладка», он выделяет «Set myPresentation = PowerPointApp.Presentations.Open (« DestinationPPT »). Пожалуйста, помогите. Любой совет искренне ценится.

'Powerpoint
Sub OpenPowerPoint()

Dim DestinationPPT As String
Dim PowerPointApp As PowerPoint.Application
Dim myPresentation As PowerPoint.Presentation

'Template Location variable
DestinationPPT = HOME.TextBox2.Value
DestinationPPT = DestinationPPT & "\Gemba Template.pptx"

Set PowerPointApp = CreateObject("PowerPoint.Application")
Set myPresentation = PowerPointApp.Presentations.Open("DestinationPPT")

'Transition from Excel to PowerPoint
Dim x, lastRow, slideNum As Integer
Dim cellName, shapeName, cellScore As String

enter image description here

1 Ответ

0 голосов
/ 09 сентября 2018

Предполагая, что ваше HOME.Textbox.Value содержит полное имя файла, единственная проблема заключается в том, что вы смешали раннее связывание объекта с поздним связыванием объекта.

'Powerpoint
Sub OpenPowerPoint()

Dim DestinationPPT As String
'You choose early binding, good choice
Dim PowerPointApp As PowerPoint.Application
Dim myPresentation As PowerPoint.Presentation

'Template Location variable
DestinationPPT = HOME.TextBox2.Value
DestinationPPT = DestinationPPT & "\Gemba Template.pptx"

'The CreateObject function is for late binding of objects
'You choose early binding.  In that case use New.
'Set PowerPointApp = CreateObject("PowerPoint.Application")
Set PowerPointApp = New PowerPoint.Application
'Assuming HOME.Textbox.Value contains a fully qualified file string
'Remove the double quote marks since DestinationPPT is a vaiable not
'a literal
Set myPresentation = PowerPointApp.Presentations.Open(DestinationPPT)

'Transition from Excel to PowerPoint
Dim x, lastRow, slideNum As Integer
Dim cellName, shapeName, cellScore As String
...