Consulting

Results 1 to 2 of 2

Thread: Solved: Run Word macro from within PPT macro

  1. #1

    Solved: Run Word macro from within PPT macro

    Hello,

    I know the PPT forum here does not get alot of action but I'm hoping someone sees this and can help.

    Short version of the question: What is the proper command to run a Word macro from a PPT macro? I've seen that it's "Project.module.macroname" but I don't know what to put for "Project."

    Longer version:

    I have been given the job to take large PPTs and "convert" them into a Word document using a specific template. So a wrote a macro to do it. The code is at the bottom of this post.

    The line I am having trouble with is the line that is commented out near the bottom. What the macro does in a nutshell is create a new Word document based on the "SMI Manual.dot" template, then it pastes all the stuff from PPT into it. At end end, I want to run a macro that is stored in the SMI Manual.dot (the macro I want to run is called "fix_ppt_import"). I found an MS KB article that said to use the syntax:

    myWD.Run "Project.module.macro"

    I've tried that, and I just don't know what to put in the "Project" slot. I've tried SMI Manual, SMI Manual.dot, TemplateProject (SMI Manual), the document name...all of them fail.

    Thanks for any help!


    [vba]Sub export_to_word()

    Dim mySlide As Slide, myShape As Shape, myDoc As Document
    Dim ShapesCount As Integer, myWD As Object
    Dim myEnd As Word.Range

    Set myWD = CreateObject("Word.Application")
    Set myDoc = myWD.Documents.Add(Template:="SMI Manual.dot")
    Set myEnd = myDoc.Range(myDoc.Sections(4).Range.End - 1, myDoc.Sections(4).Range.End - 1)

    For Each mySlide In ActivePresentation.Slides
    For Each myShape In mySlide.Shapes
    Select Case myShape.Type
    Case msoPlaceholder, msoTextBox
    Set myEnd = myDoc.Range(myDoc.Sections(4).Range.End - 1, myDoc.Sections(4).Range.End - 1)
    If myShape.HasTextFrame And myShape.TextFrame.HasText Then
    myShape.TextFrame.TextRange.Copy
    myEnd.Paste
    End If
    Case msoAutoShape
    Set myEnd = myDoc.Range(myDoc.Sections(4).Range.End - 1, myDoc.Sections(4).Range.End - 1)
    If myShape.HasTextFrame And myShape.TextFrame.HasText Then
    myShape.TextFrame.TextRange.Copy
    myEnd.Paste
    End If
    Case msoGroup, msoPicture, msoEmbeddedOLEObject, msoLinkedOLEObject, msoLinkedPicture, msoOLEControlObject, ppPlaceholderObject
    Set myEnd = myDoc.Range(myDoc.Sections(4).Range.End - 1, myDoc.Sections(4).Range.End - 1)
    myShape.Copy
    myEnd.PasteSpecial DataType:=wdPasteMetafilePicture
    ShapesCount = myDoc.Shapes.Count
    myDoc.Shapes(ShapesCount).ConvertToInlineShape
    myEnd.InsertParagraphAfter
    Case msoTable
    Set myEnd = myDoc.Range(myDoc.Sections(4).Range.End - 1, myDoc.Sections(4).Range.End - 1)
    myShape.Copy
    myEnd.Paste
    myEnd.InsertParagraphAfter
    End Select
    Next
    For Each myShape In mySlide.NotesPage.Shapes
    Set myEnd = myDoc.Range(myDoc.Sections(4).Range.End - 1, myDoc.Sections(4).Range.End - 1)
    If myShape.HasTextFrame And myShape.TextFrame.HasText Then
    myShape.TextFrame.TextRange.Copy
    myEnd.Paste
    myEnd.InsertParagraphAfter
    End If
    Next
    Next

    'myWD.Run "SMI Manual.Module3.fix_ppt_import"
    myWD.Application.Visible = True
    myWD.Application.ScreenUpdating = True
    myDoc.UndoClear
    MsgBox "Export Complete", vbInformation + vbOKOnly, "PowerPoint to Word Export"

    End Sub[/vba]

  2. #2
    Got it. FWIW,

    myWD.Application.Run "fix_ppt_import"

    did the trick.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •