继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

word提取文字

nickcau
关注TA
已关注
手记 114
粉丝 6509
获赞 303

https://img1.sycdn.imooc.com/6733eee80001e3c715780855.jpg


Sub ExtractTextToWordDoc()

Dim objPresentation As Presentation

Dim objSlide As Slide

Dim objShape As Shape

Dim objTextFrame As TextFrame

Dim objTextRange As TextRange

Dim strOutput As String

Dim objWord As Object

Dim objDoc As Object


Set objPresentation = ActivePresentation

Set objWord = CreateObject("Word.Application")

Set objDoc = objWord.Documents.Add


For Each objSlide In objPresentation.Slides

For Each objShape In objSlide.Shapes

If objShape.HasTextFrame Then

Set objTextFrame = objShape.TextFrame

Set objTextRange = objTextFrame.TextRange

strOutput = strOutput & objTextRange.Text & vbCrLf

End If

Next

Next

objDoc.Range.InsertAfter strOutput

objDoc.SaveAs "D:\Output.docx"

objDoc.Close

objWord.Quit


MsgBox "文本提取已完成!"

End Sub


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP