gpt4 book ai didi

excel - 在 VBA 中将文本 PDF 转换为 Excel

转载 作者:行者123 更新时间:2023-12-04 22:31:51 26 4
gpt4 key购买 nike

我使用了我找到的代码 here并尝试提取 PDF 文件。该代码在 Excel 中完美地提取了 PDF,但我不断收到通知消息。我已经禁用了显示警报,但它没有任何区别。

Sub ImportPDF()
Dim objWord As Object
Dim objDoc As Object
Dim wdFileName

Set objWord = CreateObject("word.Application")
wdFileName = "C:\42046_120_2077802.pdf"

Application.DisplayAlerts = False

Set objDoc = GetObject(wdFileName)

objWord.Documents.Open (wdFileName)
objWord.Selection.WholeStory
objWord.Selection.Copy

Sheets(1).Select
[A1].Select
ActiveWorkbook.ActiveSheet.Paste

'objDoc.Close ' I get an error message if I add this (Object does not support this property or method)
objWord.Quit
Application.DisplayAlerts = True
End Sub

我收到的消息如下:

File In use message

Word message convert to PDF

Word message file in use

有没有办法摆脱这些消息?

最佳答案

将您的代码更改为:

Sub ImportPDF()
Dim objWord As Object
Dim objDoc As Object
Dim wdFileName

Set objWord = CreateObject("word.Application")
wdFileName = "C:\42046_120_2077802.pdf"

Application.DisplayAlerts = False

Set objDoc = objWord.Documents.Open(wdFileName)
objWord.Selection.WholeStory
objWord.Selection.Copy

Sheets(1).Select
[A1].Select
ActiveWorkbook.ActiveSheet.Paste

objDoc.Close SaveChanges:=False
objWord.Quit
Application.DisplayAlerts = True
End Sub

关于excel - 在 VBA 中将文本 PDF 转换为 Excel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52117064/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com