【发布时间】:2019-03-21 02:44:15
【问题描述】:
1) 我通过 excel VBA 使用 Microsoft Word 打开一个 pdf。
2)从word doc,我希望只复制第3页和第4页(这两个是没有标题的表格)到excel中
3) 目前只能将整个word doc复制到excel中,比较麻烦。
下面是我的代码:
Sub convertpdftowordthenexcel()
Dim wordapp As Word.Application
Dim input1 As String
input1 = "C:\Users\Me\Desktop\Fruitjuice.pdf"
'open pdf in word
Set wordapp = New Word.Application
wordapp.documents.Open Filename:=input1, Format:="PDF Files", ConfirmConversions:=False
wordapp.Visible = True
'copy the content of the word file
wordapp.ActiveDocument.Content.Copy '<------this is where I want to change
'go to excel and paste it there
Workbooks("openpdfusingdoc.xlsm").Worksheets("Sheet1").Activate
Worksheets("Sheet1").Activate
Cells(1, 1).Select
ActiveSheet.PasteSpecial Format:="Text"
wordapp.Quit savechanges:=wdDoNotSaveChanges
End Sub
关于如何做到这一点的任何建议?
非常感谢大家!
【问题讨论】: