PDF ファイルから表をコピーして Excel に保存するマクロを実行します。一部のテーブルには空のセルが含まれており、私の分析では、空のセルの数を知る必要があります。各列を反復処理して、そのセル内の値が数値かどうかを確認する関数があります。問題は、空のセルでこの関数を実行すると true が返されることです。Isblank() 関数を使用して手動でセルをチークしようとしたところ、「false」が返されました。(貼り付けた範囲外のセルでこれを試すと、「true」が返されます)
PDFからコピーして貼り付けると、空のセルに何らかの値が貼り付けられると思います。
誰かが同様の問題に遭遇したことがありますか?もしそうなら、それを解決する方法についてのアイデアはありますか?
それが助けになる場合は、ここにコピーして貼り付けるために使用するコードがあります
'Initialize Acrobat by creating App object
Set PDFApp = CreateObject("AcroExch.App")
'Set AVDoc object
Set PDFDoc = CreateObject("AcroExch.AVDoc")
'Open the PDF
If PDFDoc.Open(PDFPath, "") = True Then
PDFDoc.BringToFront
'Maximize the document
Call PDFDoc.Maximize(True)
Set PDFPageView = PDFDoc.GetAVPageView()
'Go to the desired page
'The first page is 0
Call PDFPageView.GoTo(DisplayPage - 1)
'-------------
'ZOOM options
'-------------
'0 = AVZoomNoVary
'1 = AVZoomFitPage
'2 = AVZoomFitWidth
'3 = AVZoomFitHeight
'4 = AVZoomFitVisibleWidth
'5 = AVZoomPreferred
'Set the page view of the pdf
Call PDFPageView.ZoomTo(2, 50)
End If
Set PDFApp = Nothing
Set PDFDoc = Nothing
On Error Resume Next
'Show the adobe application
PDFApp.Show
'Set the focus to adobe acrobat pro
AppActivate "Adobe Acrobat Pro"
'Select All Data In The PDF File's Active Page
SendKeys ("^a"), True
'Right-Click Mouse
SendKeys ("+{F10}"), True
'Copy Data As Table
SendKeys ("c"), True
'Minimize Adobe Window
SendKeys ("%n"), True
'Select Next Paste Cell
Range("A" & Range("A1").SpecialCells(xlLastCell).Row).Select
'Cells(1, 1).Select
'Paste Data In This Workbook's Worksheet
ActiveSheet.Paste