Extract specific data from pdf to vba textbox

Tayl4n

Board Regular
Joined
Feb 17, 2021
Messages
84
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I hope that everything is going well with you all.

I have a code which can chose pdf clearly. However, my datas in PDF from text parts not from metada. So if I do this TextBox6.Value = acroPDDoc.GetInfo("Producer") then textbox filling as "Xyz". But I can't get the necessary information from here, such as length and weight. TextBox6 is a technical data as kVA in the PDF text section. As I understand PDF text section's type table. So I need to get the data from this table not from metada but my codes are work for metada.

So I need to fill the textbox as "400"
When I chose this PDF
Rated Power's value to TextBox6

Then result must be like :

mrexcel2.jpg


Pdf text section which included necessary data like this:
mrexcel.jpg




Pdf metada like this:
Title
Subject
Keywords
Author
Creator
ProducerXyz
CreationDateFri Dec 23 17:51:01 2022
ModDateFri Dec 23 17:55:55 2022
Taggedno
UserPropertiesno
Suspectsno
Formnone
JavaScriptno
Pages2
Encryptedno
Page size595 x 842 pts (A4)
Page rot0
File size317234 bytes
Optimizedno
PDF version1.4






VBA Code:
Private Sub CommandButton3_Click()

Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.Filters.Clear
fd.Filters.Add "PDF Files", "*.pdf"
If fd.Show = False Then Exit Sub


Dim acroApp As acroApp
Dim acroAVDoc As acroAVDoc

Dim acroPDDoc As acroPDDoc
Set acroApp = CreateObject("AcroExch.App")
Set acroAVDoc = CreateObject("AcroExch.AVDoc")
If acroAVDoc.Open(fd.SelectedItems(1), "") Then
Set acroPDDoc = acroAVDoc.GetPDDoc
Else
MsgBox "Error opening PDF file"
Exit Sub
End If

TextBox6.Value = acroPDDoc.GetInfo("Producer")



acroAVDoc.Close True
Set acroPDDoc = Nothing
Set acroAVDoc = Nothing
Set acroApp = Nothing

End Sub
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hello again everyone. It is an urgent and important project please help :(
 
Upvote 0
As far as I collect the information I can use findtext but I don't know how. I can't find an example
 
Upvote 0
Is there anyone who can help or guide me? This is an important issue :(
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,100
Members
452,301
Latest member
QualityAssurance

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top