Ошибка VBA Powerpoint на Mac при объединении презентаций с ActivePresentation.Slides.InsertFromFile - PullRequest
0 голосов
/ 20 сентября 2019

Цель моих усилий - создать макрос VBA, который объединит несколько презентаций PPT в одну презентацию PPT.Презентации компонентов, которые должны быть объединены, находятся в нескольких местах.Это кажется решающим фактором.Я нашел очень хорошее «почти» решение, но оно основывалось на том, что все презентации компонентов были в одной папке.Мне удалось изменить пример, но ActivePresentation.Slides.InsertFromFile будет работать только в том случае, если путь к представлению компонента жестко задан.Мне нужно, чтобы это управлялось данными.Когда я пытаюсь сослаться на переменную, содержащую путь, ActivePresentation.Slides.InsertFromFile завершается с ошибкой «Ошибка вставки файлов Ошибка: -2147483640 Powerpoint не может открыть файл».

Любая помощь, чтобы запустить это, передавпуть компонента как переменная был бы очень признателен.Спасибо, Джек

Содержимое файла MANIFEST.txt состоит из двух строк:тема-1 / контрольно-structures.pptmtopic-2 / cursors.pptm

Sub InsertExample()
' Inserts all presentations named in MANIFEST.txt into current presentation in list order
' MANIFEST.txt must be properly formatted, one full path name per line

    On Error GoTo ErrorHandler

    Dim ManifestFileName As String
    Dim ManifestFilePathColons As String
    Dim ManifestFilePathSlashes As String
    Dim iListFileNum As Integer
    Dim ManifestPresentationName As String

    Dim FullPresentationPath As String

    ' name of file containing files to be inserted
    ManifestFileName = "MANIFEST.txt"

    ' use the path with colons to work with the MANIFEST.txt file
    ManifestFilePathColons = "Macintosh HD:Users:freejak:Google Drive:stirling:course-topics:auto-consolidate:"

      ' use the path with slashes to work with the ActivePresentation.Slides.InsertFromFile PPT method
    ManifestFilePathSlashes = "Macintosh HD/Users/freejak/Google Drive/stirling/course-topics/auto-consolidate/"

    ' Do we have a file open already?
    ' Debug.Print Presentations.Count
    If Not Presentations.Count > 0 Then
        Exit Sub
    End If

    iListFileNum = FreeFile()
    Open ManifestFilePathColons & ManifestFileName For Input As iListFileNum

    ' Process the list
    While Not EOF(iListFileNum)
        ' Get a line from the list file
        Line Input #iListFileNum, ManifestPresentationName

            'The following invocation works, and the seperator must be a slash
        Call ActivePresentation.Slides.InsertFromFile("Macintosh HD/Users/freejak/Google Drive/stirling/course-topics/auto-consolidate/topic-1/control-structures.pptm", _
              ActivePresentation.Slides.Count)

        FullPresentationPath = ManifestFilePathSlashes & ManifestPresentationName

        'This invocation fails, the same error occurs if I call passing "ManifestFilePathSlashes & ManifestPresentationName" without the quotes
        ' This fails whether the seperators are colons or slashes
        ' Call ActivePresentation.Slides.InsertFromFile(FullPresentationPath, ActivePresentation.Slides.Count)

    Wend

    Close #iListFileNum
    MsgBox "DONE!"

NormalExit:
    Exit Sub

1 Ответ

0 голосов
/ 21 сентября 2019

Не уверен, что это уместно, но у вас есть дополнительная подпапка "topic1" при вводе пути против пути, записанного в строковые переменные.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...