从PowerPoint 2010中向Word 2010发送命令 [英] Sending a command to Word 2010 from within PowerPoint 2010

查看:79
本文介绍了从PowerPoint 2010中向Word 2010发送命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 - 我我试图将每张PowerPoint幻灯片的内容粘贴到Word文档中,以便我可以使用"跟踪更改" - PP中遗漏了
功能。无论如何,到目前为止,我有这个代码:




Sub tryit2( )

Dim myWd As Word.Application

< span style ="color:#333333; font-family:Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif; font-size:13px; backgro und-color:#fafafa">设置myWd = New Word.Application





使用myWd

。可见=真

。Documents.Add





对于j = 1到3

演示文稿(1).Slides(j).Shapes.Range.Copy



使用.Documents(1)

.Range.Paste

结束

下一个j



。退出

结束





End Sub



这会将幻灯片1到3上的所有素材粘贴到Word中,但每组形状都会粘贴到文档的单页上;
我希望每张幻灯片的形状都显示在我已经尝试了多种方法在这个宏中向Word发送分页命令,但没有运气。有人可以帮忙吗?谢谢!

Hi--I'm trying to paste the contents of each PowerPoint slide into a Word document so that I can use "Track Changes"--a feature sadly missing in PP. Anyway, so far I have this code:

Sub tryit2()
Dim myWd As Word.Application
Set myWd = New Word.Application


With myWd
.Visible = True
.Documents.Add


For j = 1 To 3
Presentations(1).Slides(j).Shapes.Range.Copy

With .Documents(1)
.Range.Paste
End With
Next j

.Quit
End With


End Sub

This does paste all of the material on slides 1 to 3 into Word, but each set of shapes is pasted onto the single page of the document; I want each slide's shapes to appear on separate pages. I've tried a variety of ways to send a page break command to Word within this macro, but no luck. Can anyone help? Thanks!

推荐答案

使用VBA操作PowerPoint(或任何办公应用程序)中的Word对象基本相同。请尝试以下操作:

Manipulation the Word object from PowerPoint (or any of the office apps) with VBA  is essentially the same. Try the following:

Option Explicit

Sub tryit3()
'Graham Mayor - http://www.gmayor.com - Last updated - 13/12/2016'
Dim myWd As Object
Dim oRng As Object
Dim oDoc As Object
Dim j As Long

    On Error Resume Next
    Set myWd = GetObject(, "Word.Application")
    If Err Then
        Set myWd = CreateObject("Word.Application")
    End If

    With myWd
        .Visible = True
        Set oDoc = .Documents.Add
        oDoc.PageSetup.Orientation = 1
    End With

    For j = 1 To 3
        Presentations(1).Slides(j).Shapes.Range.Copy
        If j > 1 Then
            Set oRng = oDoc.Range
            oRng.collapse 0
            oRng.insertbreak 7
        End If
        Set oRng = oDoc.Range
        oRng.collapse 0
        oRng.Paste
    Next j
lbl_Exit:
    Set myWd = Nothing
    Set oDoc = Nothing
    Set oRng = Nothing
    Exit Sub
End Sub


这篇关于从PowerPoint 2010中向Word 2010发送命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆