从PowerPoint 2010中向Word 2010发送命令
嗨 - 我我试图将每张PowerPoint幻灯片的内容粘贴到Word文档中,以便我可以使用"跟踪更改" - PP中遗漏了
功能。无论如何,到目前为止,我有这个代码:
Sub tryit2( )
Dim myWd As Word.Application
设置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