我想使用Word文档在特定文件夹中打开许多pdf文件,然后复制内容并粘贴到我的Excel工作表中,而无需更改格式。我编写的代码仅在显示运行时错误462后才能执行2个pdf文件的任务-远程服务器计算机不存在或不可用。请帮助我出什么事了,我该如何解决?预先感谢。
Sub test()
Dim s As String
Dim path As String
Dim col As Integer: col = 1
Dim t As Excel.Range
path = "C:\Users\121919\Desktop\Direct Dispatch Report_PENS\29 Jul\PDF to Word Try\"
s = Dir(path & "*.pdf")
Do Until s = ""
Dim wd As New Word.Application
Dim mydoc As Word.document
Set mydoc = Word.Documents.Open(Filename:=path & s, Format:="PDF Files", ConfirmConversions:=False)
Dim wr As Word.Range
Set wr = mydoc.Paragraphs(1).Range
wr.WholeStory
Set t = ThisWorkbook.Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
wr.Copy
t.PasteSpecial xlPasteValues
mydoc.Close False: s = Dir
wd.Quit '<- This is where the code stops and throw error
Loop
End Sub