Kalkytron
Kalkytron
  • Видео 12
  • Просмотров 60 078
VBA + GPT to categorize and extract data from documents (IDP)
💡 In this video, you'll explain and run the Intelligent Document Processing script in VBA.
🔗 Useful Links and Resources:
📂 GitHub: github.com/Alpsure/AI-agenticIDP-VBA/tree/main
❤️ Support the Channel:
raydium.io/swap/?inputMint=sol&outputMint=6fbfhKarUkbqErJrYcmy69LzdgNChzaR8KNttdJAVquN&referrer=G3HnhtxR5GgoK5MC3fDaRQi7v8HdBQcs1sih1SnPGyVA
00:00: Intro
00:28: Setup Excel
01:19: Install OCR
02:14: Setup project folder
02:50: Download from GitHub
03:45: High level explanation
04:24: Code walk through
11:00: Demo
There is no outro.
Просмотров: 50

Видео

VBA Beginner: Functions and Sub Procedures
Просмотров 12 тыс.7 лет назад
In this video, I show what Functions and Sub Procedures are for, and how to use them. Code:
VBA Expert: Handling popups with API (Write)
Просмотров 1,3 тыс.7 лет назад
💡 In this video, you'll learn how to send text to a field in other applications with VBA. 🔗 Useful Links and Resources: 📂 GitHub: github.com/Alpsure/automation-windowsUIwrite/blob/main/write_to_app_from_VBA.vba ❤️ Support the Channel: raydium.io/swap/?inputMint=sol&outputMint=6fbfhKarUkbqErJrYcmy69LzdgNChzaR8KNttdJAVquN&referrer=G3HnhtxR5GgoK5MC3fDaRQi7v8HdBQcs1sih1SnPGyVA
VBA Expert: VBA & Shell Function With Arguments
Просмотров 3,7 тыс.7 лет назад
💡 In this video, you'll learn how to call other applications from VBA. CODE CHANGE: "RetVal = VBA." instead of "Call": RetVal = VBA.shell("""" & path_popup_handler & """ """ & window_name & """ """ & button_name & """", vbNormalFocus) ❤️ Support the Channel: raydium.io/swap/?inputMint=sol&outputMint=6fbfhKarUkbqErJrYcmy69LzdgNChzaR8KNttdJAVquN&referrer=G3HnhtxR5GgoK5MC3fDaRQi7v8HdBQcs1sih1SnPGyVA
VBA Beginner: 04. Conditionals
Просмотров 1167 лет назад
Conditionals - What is a conditional? - If... Then... End if - Others * Variations on If... Then... End if * Select... Case
VBA Expert: Handling pop-ups with APIs
Просмотров 8 тыс.7 лет назад
Note: The pop-up is from Cute PDF Printer, not MS Word. Excel with the script: will follow Cute PDF Writer: www.cutepdf.com/ Alex Cantu: ruclips.net/user/alexcantu3
VBA Expert: Reading Scanned PDF's
Просмотров 33 тыс.8 лет назад
Working example: drive.google.com/file/d/1-vCvJRWg6m6k1d23_fRC2NyQ0q4vsAdP/view?usp=sharing [updated on 19.01.2021] Tools: Magick and Tesseract Tesseract: github.com/tesseract-ocr/tesseract Variables: ruclips.net/video/jVP0L8wBFLA/видео.html Loops: ruclips.net/video/U1BkhzzL4IA/видео.html Conditionals / API's / Shell ruclips.net/video/YiHVMF5N9BY/видео.html FSO library /
VBA Beginner: 03. Loops
Просмотров 2798 лет назад
Overview: 1. What are loops? 2. Do While...Loop 3. Other loop options 3.1 Do Until...Loop 3.2 Do...Until Loop & Do...While Loop 3.3 For...Next
VBA Beginner - 01. Introduction
Просмотров 3028 лет назад
1. Setup 2. The 4 cornerstones of VBA 3. For whom?
VBA Beginner: 02. Variables
Просмотров 3898 лет назад
Overview: 1. An explanation of the concept of variables 1.1 Variable = box 1.2 Variables hold data 1.3 Basic maths (x = 2 3) 2. Examples 2.1 cAmount example 2.2 cGross, cNetto and cVAT example 2.3 cGross, cNetto, cVAT and sOutput example 3. Why? 3.1 Clear writing style 3.2 Data mobility

Комментарии

  • @TuanNguyen-sy1dx
    @TuanNguyen-sy1dx 6 месяцев назад

    Thank u so much. I love you bro

  • @ganeshs1360
    @ganeshs1360 Год назад

    Please share the code

    • @kalkytron
      @kalkytron 27 дней назад

      Remind me again tomorrow. Thanks.

    • @ganeshs1360
      @ganeshs1360 26 дней назад

      Hi. You asked me to remind you. Please share the code. Thank you

    • @kalkytron
      @kalkytron 26 дней назад

      ​@@ganeshs1360 Hi Ganesh, I've stored the code here: github.com/Alpsure/automation-windowsUIwrite/tree/main I haven't been able to test it lately. In the next week or 2 I'll go through these old projects and check whether they still work.

    • @ganeshs1360
      @ganeshs1360 26 дней назад

      Thank you for uploading. I will check this sometime next week

    • @kalkytron
      @kalkytron 17 дней назад

      How did it go?

  • @joshuacastrudes25
    @joshuacastrudes25 Год назад

    Your viewer wont understand what you are talking about if you just read it from your notes....

    • @kalkytron
      @kalkytron 27 дней назад

      You might have a point.

  • @querrythis
    @querrythis Год назад

    Best explanation I've found. Very clear on declaration and how the values are passed. Very much appreciated.

    • @kalkytron
      @kalkytron 27 дней назад

      Thanks! Any other topic that would be useful for you?

  • @sajjadabouei6721
    @sajjadabouei6721 2 года назад

    thank you really helpful ✌

    • @kalkytron
      @kalkytron 27 дней назад

      Thanks. Let me know if there are any other topics you want a tutorial about. I'm returning.

  • @matewojno2103
    @matewojno2103 2 года назад

    I am trying to ocr scan documents in pol then extract only sepecific boxes and paste or import them to excel table, i have solution in mind but not enough programming knowledge.

  • @jeronimo6159
    @jeronimo6159 2 года назад

    Hi do you do paid work? If so how do I contact you

    • @kalkytron
      @kalkytron 27 дней назад

      Yes. Make me an offer I can't refuse!

  • @BRVR_
    @BRVR_ 2 года назад

    Hello, Could you say how can i put a higher resolution in output JPG. files ?I see that in the process from PDF to JPG - VBA does JPG very small and unrecognizable for Tesseract. When VBA tries to recognize the text from JPG. it shows in Command Line: Resolution 98 and mostly gives "abracadabra" result in TXT. I think i should put here some Command like magick convert inpur.pdf -resize 150% -quality 200 output.jpg Call Shell(sMagick & " """ & oFile.Path & """ """ & Left(oFile.Path, Len(oFile.Path) - 3) & "jpg" & """", vbNormalFocus) 'Run Magick: PDF to JPG

    • @kalkytron
      @kalkytron 25 дней назад

      Good question... I'm going through these projects in the next week or 2.

  • @bredmond812
    @bredmond812 2 года назад

    I thought you were going to explain to get the handle of a child after the button to call it was clicked by the parent. I'm trying to do that and the code stalls after the child window appears.

    • @kalkytron
      @kalkytron 27 дней назад

      If a popup appears in an ms office window then the vba running in a ms office program like excel will pause until the popup is handled. So you need to run the handling script outside. Eg in a vbs.

    • @bredmond812
      @bredmond812 27 дней назад

      @@kalkytron do you know how to do it with C#?

    • @kalkytron
      @kalkytron 27 дней назад

      ​@@bredmond812 not right away...but I can take a look sometime next week.

    • @bredmond812
      @bredmond812 27 дней назад

      @@kalkytron no problem. If I can wait two years for the first response, I can wait some more

    • @kalkytron
      @kalkytron 26 дней назад

      @@bredmond812 That's the spirit! Anyway, I've got the C# solution working. I'll upload it to GitHub shortly.

  • @fengfuxu4822
    @fengfuxu4822 2 года назад

    if popup window is from Excel, then this procedure cannot handle? so this procedure can only handle popup windows raised from programs other than Excel?

    • @kalkytron
      @kalkytron 26 дней назад

      VBA Will pause if a popup appears in a MS Office app. That's why you need to start a separate script (eg in vbs) BEFORE the popup appears such that the launched script can handle the popup. Let me know if I'm still unclear.

  • @gayatrishivhare3537
    @gayatrishivhare3537 3 года назад

    Hello could you please help me with Vbs file also.. like can we use in Vbs these parameters

    • @kalkytron
      @kalkytron 27 дней назад

      I'm not fully getting the question. Please elaborate

  • @robertogallardo8157
    @robertogallardo8157 3 года назад

    Hello Mister, I'm trying to implement this code. I'm having issues with finding the "File name" and the file name text box. I'm thinking that windows 10 has a different way to pipoint this elements from the save as window. Do you know something about that?

    • @kalkytron
      @kalkytron 26 дней назад

      Sir, I'll investigate this issue in the coming days.

    • @kalkytron
      @kalkytron 24 дня назад

      Sir, I've made slight changes to the code. This version was tested today: github.com/Alpsure/automation-windowsUIwrite/blob/main/write_to_app_from_VBA.vba

  • @bcapp7937
    @bcapp7937 3 года назад

    Thanks very much for sharing this. You mentioned that you have a 2.0 version where you put Tesseract and Unar (apparently Magick now) zip files the code, could you share the code/file on this? Thanks!

    • @kalkytron
      @kalkytron 26 дней назад

      Hi, I'm going through these old projects. In the next week or 2 you'll find the links to the code in the updated video description.

  • @drag1c
    @drag1c 3 года назад

    Hi Kalkytron ! I am using Professional 2013, magick 7.0.11 and tess 5. Is there chance your excel file not work with them? Ofcourse, I changed source parts of your excel file. Also, to point out, I do not have Microsoft Excel 16.0 Object Library. I have Microsoft Excel 15.0 Object Library. The same is with Microsoft Excel 16.0 Office Library. The problem is I have infinite loading and excel take 0 MB of ram. It goes into bug.

    • @drag1c
      @drag1c 3 года назад

      I've found out Shell function does not work properly for part: Converting from PDF to JPG. Simply, when I run it, I dont get JPG file. I've tried Part 4 of program on JPG file (manually added JPG file with text into folder) and it works. Do you know how to fix Shell part for PDF to JPG?

  • @munimrashid7065
    @munimrashid7065 3 года назад

    Thank you indeed for the code and the presentation. Now please correct me if I am wrong. Finally Magick was used instead of Unar which can be downloaded from imagemagick.org/script/download.php

  • @TheMuralipandu
    @TheMuralipandu 4 года назад

    Can u share code pl

    • @kalkytron
      @kalkytron 26 дней назад

      Hi. You can find the original code here: github.com/Alpsure/automation-windowsUIwrite I haven't tested it yet of late but will do so in the next week or two.

  • @deandog7223
    @deandog7223 4 года назад

    Hi @Kalkytron, possible that you still might have the working source-code?

    • @kalkytron
      @kalkytron 4 года назад

      Hi DeanDog. Try this link: drive.google.com/file/d/1-vCvJRWg6m6k1d23_fRC2NyQ0q4vsAdP/view?usp=sharing It's an updated version.

  • @travllingisfun6189
    @travllingisfun6189 4 года назад

    Your videos are very interesting please upload more videos.. Related to web automation with vba..

    • @kalkytron
      @kalkytron 26 дней назад

      Still interested?

  • @Computer_Scientist786
    @Computer_Scientist786 5 лет назад

    I am facing a problem.....I want to click ok on pop up message ,that appears on Excel sheet, using vba code..... please tell me command..... thanks in advance

    • @kalkytron
      @kalkytron 26 дней назад

      You could use this solution to handle to popup: github.com/Alpsure/automation-windowsHandling

    • @Computer_Scientist786
      @Computer_Scientist786 25 дней назад

      @kalkytron thanks

  • @jetzza1995
    @jetzza1995 5 лет назад

    Hi Bart, can we please get the working example link ,this would be very helpfull for us

    • @AlpsureTeam
      @AlpsureTeam Месяц назад

      Hey. I got a working example in python. Let me know if you would like one in VBA as well!

  • @joem112
    @joem112 5 лет назад

    Thank-you for the video. It is very clear you are a great teacher. The code worked great on my computer. I tried to use it on a colleague's computer. And the code froze on the outer loop after 267 handles. His computer processor is not as fast as mine. Is there a change that can me made to the code to accommodate a slower processor?

    • @joem112
      @joem112 5 лет назад

      Sorry we were having network problems and that appears to have been the cause of the problem.

    • @kalkytron
      @kalkytron 27 дней назад

      But late...but are you still facing issues?

  • @brt5808
    @brt5808 5 лет назад

    Thanks Bart for this video! Great job! I have one question, do you have source of good knowledge for Windows API and how to deal with in VBA?

    • @kalkytron
      @kalkytron 26 дней назад

      Hi Bert. It's honestly a pain in the bottom to find good documentation with clear examples on this topic. I'm reviewing these old projects and will update the description with useful documentation if I find some.

  • @Eric-pi2rn
    @Eric-pi2rn 5 лет назад

    Hi, Anyone with a working version of this? I tried by manually copying everything, but had no Luck ... This would be exactly what I Need -.-

    • @kalkytron
      @kalkytron 4 года назад

      Hi Eric. Here is an updated version: drive.google.com/file/d/1-vCvJRWg6m6k1d23_fRC2NyQ0q4vsAdP/view?usp=sharing

  • @tioadjie5361
    @tioadjie5361 5 лет назад

    Dear all, if somebody here can do what this video explain and it works, please email me to tioadibayu@gmail.com. I have interesting reward for you

  • @tioadjie5361
    @tioadjie5361 6 лет назад

    Hi Sir. I have interesting offer for you. Do you have email ?

    • @kalkytron
      @kalkytron 27 дней назад

      Make me an offer I can't refuse

  • @tioadjie5361
    @tioadjie5361 6 лет назад

    Dear sir, there is interesting offer for you. Please email me at tioadibayu@gmail.com. Thank you.

  • @slipvanei
    @slipvanei 6 лет назад

    Thanks this helps very much

  • @slipvanei
    @slipvanei 6 лет назад

    Great

  • @KhalilYasser
    @KhalilYasser 6 лет назад

    Thanks a lot. As for the working example link is not found .. Can you update please?

  • @romanlight5525
    @romanlight5525 6 лет назад

    hello can you update example link?

  • @ThePimentajoao
    @ThePimentajoao 6 лет назад

    Hi there! I find this video very usefull ! Could you please help me by posting the code in answer or update the links plz? Thanks in advance for the help! João Pimenta

  • @daviddarby3738
    @daviddarby3738 6 лет назад

    Complex code and no demo?

  • @sviatoslavdoroshenko345
    @sviatoslavdoroshenko345 7 лет назад

    Hello Bart thank you for you code. It's working perfect, but when file with the same name exist then vba is throwing me the confirmation message "Confirm save as". I tried to develop the "Child3", but vba is freezing on moment confirmation message appears. Thank you:)

    • @kalkytron
      @kalkytron 7 лет назад

      Hi Sviatoslav. Is the problem that VBA doesn't go to the next line of code until the extra popup disappeared?

    • @sviatoslavdoroshenko345
      @sviatoslavdoroshenko345 7 лет назад

      Hello Bart, thank you for reply. Yes, correct. Can you advice some workaround?

    • @kalkytron
      @kalkytron 7 лет назад

      Hi Sviatoslav. I've encountered this issue as well in the past. I am not sure where the script is but here is what I did: First, create a vbs script to push the button which loops until the button is found. Next, call the script just before the line where your VBA script stops. If this isn't clear enough then I'll try to explain it in more detail at a later point.

    • @sviatoslavdoroshenko345
      @sviatoslavdoroshenko345 7 лет назад

      Hi Bart, thank you for reply. I found video on youtube explaining the idea you described - ruclips.net/video/G-2khNFYQl8/видео.html . But I'm just wondering is there way loop for intial window "save as" as well and do it in one vbs script.

  • @D3_Business_Analytics
    @D3_Business_Analytics 7 лет назад

    The link is not working dear

  • @daytodatainc.2520
    @daytodatainc.2520 7 лет назад

    Hello, the links are not working. Can you please update?

  • @lexlopez81
    @lexlopez81 7 лет назад

    Bart, my vba is throwing me the next message when i copy the code: "The code in this project must be updated for use on 64-bit systems. Please review and update Declare statements and then mark them with PtrSafe attribute" Can you help me with this??

    • @kalkytron
      @kalkytron 7 лет назад

      Hi Alejandro More. The declaration of the API's is slightly different for the 64bit system than the 32bit system. You need to add "PtrSafe" after "Declare".

  • @miguelangelsorianobueno5816
    @miguelangelsorianobueno5816 7 лет назад

    Hello Working Example link doesn´t work anymork. Could you fix it please? TY!!!!

  • @chriscatterall4698
    @chriscatterall4698 7 лет назад

    Thanks for the really useful video I am trying to recreate this code using MS Excel 2010 on Windows 10. Is there a Window equvilent for Unar and Tessract, or is this solution only for Mac? Thanks again for your help.

    • @kalkytron
      @kalkytron 7 лет назад

      Hi Chris. The video is made on a Windows machine. So Unar and Tesseract definitely work on there. Also, MS Excel 2010 is fine.

    • @chriscatterall4698
      @chriscatterall4698 7 лет назад

      Hi Bart, Thanks for your reply. I managed to find the Windows versions of Unar and Tesseract, and have downloaded your example spreadsheet. I had the same problem with the Shell command as Andre. I therefore substituted Andre's code (i.e. Function PDF_To_Txt down to ==================Put all the txt files into 1 & rename======================= .... End Function. I changed the file directory locations for my computer. However I get a runtime error '53' File not found message, and the 'Call Shell(spdfEx & " " & """" & sPDF & """ """ & sTXT & """", vbNormalFocus)' line of code immediately below ==============Convert PDF to TXT====================== is highlighted. I've pasted the end of the code below. Am I missing something obvious? I'd be grateful if you could take a look. Thanks again. Chris Function PDF_To_Txt(sPDF As String) 'Tools -> Reference -> Microsoft Scripting Runtime 'Process: ' - PDF to JPG/TIFF with Unar --> output is 1 picture per PDF page ' - Make sure the pictures are in the correct folder ' - JPG's to TXT's ' - All TXT's into 1 TXT ' - Collect everything in an Output folder 'To do: ' - If picture; don't call Unar, but straight to Teseract ' - Add .exe and dll's to Macro ' - Check whether files already exist before creating them Dim sPath As String Dim spdfEx As String Dim sTesseract As String Dim sUnar As String Dim sTXT As String Dim i As Integer Dim iSlashCounter As Integer Dim iPageCounter As Integer Dim sPDFname As String Dim sNewPath As String Dim FSO As Scripting.FileSystemObject Dim fsoFolder As Scripting.Folder Dim fsoFile As Scripting.File Dim fsoFile2 As Scripting.File Dim oTxt As Object Dim oTxtGet As Object Dim sAPI As String Set FSO = CreateObject("Scripting.FileSystemObject") iPageCounter = 1 If UCase(Right(sPDF, 3)) <> "PDF" Then Exit Function End If 'Get Path and PDF name from dir iSlashCounter = 0 For i = Len(sPDF) To 1 Step -1 If Mid(sPDF, i, 1) = "\" Then iSlashCounter = iSlashCounter + 1 If iSlashCounter = 2 Then sPath = Mid(sPDF, 1, i) Exit For ElseIf iSlashCounter = 1 Then sPDFname = Mid(sPDF, i + 1) sPDFname = Mid(sPDFname, 1, Len(sPDFname) - 4) End If End If Next i If FSO.FolderExists(sPath & "Output") = False Then MkDir sPath & "Output\" Sleep 500 End If sUnar = sPath & "unar.exe" 'PDF to JPG converter sTesseract = sPath & "Tesseract\tesseract.exe" 'JPG to TXT converter spdfEx = sPath & "pdfEx\pdfExtractor.exe" sTXT = sPath & sPDFname & ".txt" '==============Convert PDF to TXT====================== Call Shell(spdfEx & " " & """" & sPDF & """ """ & sTXT & """", vbNormalFocus) sAPI = FindWindow(vbNullString, spdfEx) i = 0 Do Until sAPI <> "0" Or i >= 50 'Catch the screen Sleep 50 sAPI = FindWindow(vbNullString, spdfEx) i = i + 1 Loop i = 0 Do Until sAPI = "0" Or i >= 50 'loop until the screen is away Sleep 500 sAPI = FindWindow(vbNullString, spdfEx) i = i + 1 Loop 'Check whether there is something in the file Set oTxtGet = FSO.OpenTextFile(sTXT, ForReading) If FileLen(sTXT) <= 2 Then '(FileLen returns 2 in case of an empty file) oTxtGet.Close Kill sTXT Else oTxtGet.Close FileCopy sTXT, sPath & "Output\" & sPDFname & ".txt." Kill sTXT Exit Function End If '=================Convert PDF to picture=================

    • @kalkytron
      @kalkytron 7 лет назад

      Hi Chris, I noticed that the code I uploaded contained more than what I explained in the video. I first call an app to directly read the PDF to TXT. This one doesn't work for scans but goes a lot faster. So only if this fails I go to Unar & Tesseract. In any case, I'm sorry for the confusion. Regarding the error in the shell, I created this video to explain the shell function and what to pay attention to: ruclips.net/video/YiHVMF5N9BY/видео.html

  • @Lucian0623
    @Lucian0623 7 лет назад

    thank you for the video!! keep it up!

    • @kalkytron
      @kalkytron 24 дня назад

      I will!....with a slight delay, But 100 times the experience and knowledge!

  • @danielohlsson3649
    @danielohlsson3649 7 лет назад

    Hi, thanks for a helpful video. I'm however trying to read scanned documents (I have them as .tif files) that have a few check boxes, and I would like to know which of the check boxes have a check mark in them. Do you know if Tesseract supports this kind of issue? I have read about OMR (Optical Mark Recognition) but I haven't found anything for custom implementation in VBA or Python, which are the languages I know. Thank you for your help!

    • @kalkytron
      @kalkytron 7 лет назад

      Hi Daniel. I haven't used Tesseract with .tiff files. Also, Tesseract doesn't return anything for check boxes when read from a JPG file. But when I google "Tesseract tif" then I immediately get some possibly useful hits. I suggest you try to make it work at the command prompt first based on those articles. Once you've covered that you can move it to the script.

  • @andrejackson6020
    @andrejackson6020 7 лет назад

    Hi Bart, thanks for the video, i'm having some issues with the shell command. Please help!

    • @kalkytron
      @kalkytron 7 лет назад

      Hi Andre. Can you paste the code here that you are using? And maybe the error you are getting as well

    • @andrejackson6020
      @andrejackson6020 7 лет назад

      I found the code that was on the original downloadable version was different to the code that was at the end of the video, maybe i'm wrong. I'm only interested in the Unar and Tesseract parts; when i execute the code (F8), it seems that its skipping the Unar part and is trying to convert the PDF directly to a text file rather than going through the whole process. Thanks in advance. Function PDF_To_Txt(sPDF As String) 'Tools -> Reference -> Microsoft Scripting Runtime 'Process: ' - PDF to JPG/TIFF with Unar --> output is 1 picture per PDF page ' - Make sure the pictures are in the correct folder ' - JPG's to TXT's ' - All TXT's into 1 TXT ' - Collect everything in an Output folder 'To do: ' - If picture; don't call Unar, but straight to Teseract ' - Add .exe and dll's to Macro ' - Check whether files already exist before creating them Dim sPath As String sPath = "C:\Users\Andre\Desktop\Tesseract-OCR\Tesseract\ReadPDFs\" Dim i As Integer Dim iSlashCounter As Integer Dim iPageCounter As Integer Dim sPDFname As String Dim fsoFolder As Scripting.Folder Dim fsoFile As Scripting.File Dim fsoFile2 As Scripting.File Dim oTxt As Object Dim oTxtGet As Object Dim sAPI As Long Dim FSO As Scripting.FileSystemObject Dim oFolder As Scripting.Folder Dim oFile As Scripting.File Dim sFolder As String Dim sUnar As String Dim sTesseract As String Dim sTxt As String Dim sNewPath As String Set FSO = CreateObject("Scripting.FileSystemObject") sFolder = "C:\Users\Andre\Desktop\Tesseract-OCR\Tesseract\ReadPDFs" Set oFolder = FSO.GetFolder(sFolder) sUnar = "C:\Users\Andre\Desktop\Tesseract-OCR\Tesseract/" & "unar.exe" sTesseract = "C:\Users\Andre\Desktop\Tesseract-OCR\Tesseract" & "/Tesseract.exe" iPageCounter = 1 For Each oFile In oFolder.Files sTxt = sFolder & oFile.Name & "convert" sNewPath = sFolder & "\" & oFile.Name & "pdf" '==============Convert PDF to TXT====================== Call Shell(sUnar & " " & """" & oFile.Name & """", vbNormalFocus) 'Run Unar: PDF to JPG sAPI = FindWindow(vbNullString, sUnar) i = 0 Do Until sAPI <> "0" Or i >= 50 'Catch the screen Sleep 50 sAPI = FindWindow(vbNullString, sUnar) i = i + 1 Loop i = 0 Do Until sAPI = "0" Or i >= 50 'loop until the screen is away Sleep 500 sAPI = FindWindow(vbNullString, sUnar) i = i + 1 Loop 'Check whether a folder is made by unar. If not; make one and copy the jpg to it If FSO.FolderExists(sNewPath) = False Then MkDir sNewPath Do Until FSO.FolderExists(sNewPath) = True Sleep 100 Loop Dim SourceFile, DestinationFile As String SourceFile = sPath & oFile.Name 'Define source file name. DestinationFile = sNewPath & oFile.Name 'Define target file name. 'Copy the jpg to the newly created folder Set oFolder = FSO.GetFolder(sPath) If Mid(oFile.Name, 1, 4) = "Page" Then FileCopy SourceFile, DestinationFile Sleep 500 Kill sPath & oFile.Name Sleep 500 Exit For End If End If Call Shell(Chr(34) & sTesseract & Chr(34) & " " & Chr(34) & sNewPath & oFile.Name & Chr(34) & " " & Chr(34) & sTxt & Chr(34), vbNormalFocus) sAPI = FindWindow(vbNullString, sTesseract) i = 0 Do Until sAPI <> "0" Or i >= 50 'Catch the screen Sleep 50 sAPI = FindWindow(vbNullString, sTesseract) i = i + 1 Loop i = 0 Do Until sAPI = "0" Or i >= 50 'Loop until the screen is away Sleep 500 sAPI = FindWindow(vbNullString, sTesseract) i = i + 1 Loop Next oFile '==================Put all the txt files into 1 & rename======================= Set oFolder = FSO.GetFolder(sNewPath) sTxt = sNewPath & sPDFname & ".txt" Set oTxt = FSO.CreateTextFile(sTxt, True) 'Create new txt file Do Until FSO.FileExists(sTxt) = True Sleep 100 Loop For Each oTxtGet In oFolder.Files 'Loop through other files and copy text If CStr(oTxtGet) <> sTxt Then Set oTxtGet = FSO.OpenTextFile(oTxtGet, ForReading) Sleep 1500 On Error Resume Next oTxt.WriteLine (oTxtGet.ReadAll) On Error GoTo 0 oTxt.WriteLine (" _-_-_-_-_-_-_-_-_- " & "Page " & iPageCounter & " _-_-_-_-_-_-_-_-_- ") oTxtGet.Close iPageCounter = iPageCounter + 1 End If Next oTxtGet oTxt.Close 'Copy txt file to an output folder On Error Resume Next MkDir sPath & "Output\" On Error GoTo 0 FileCopy sTxt, sPath & "Output\" & sPDFname & ".txt" On Error Resume Next Kill sNewPath & "*" 'delete all files in folder Do Until Err.Number = 0 On Error GoTo 0 On Error Resume Next Kill sNewPath & "*" 'delete all files in folder Sleep 200 Loop On Error GoTo 0 End Function

    • @kalkytron
      @kalkytron 7 лет назад

      Hi Andre, I don't recommend walking through the code with F8 because the code is trying to find windows and handle them. You might interrupt this by always going back to the VBE. Also, the code you show starts with running Unar. So that seems OK.... I do have a version in which I first try to read the PDF with a different console app (works in case of eg Word files saved as PDF). If this fails then I go for Unar and Tesseract. In any case, I don't think that I have this in the uploaded version on Dropbox.

  • @MrFhansen3
    @MrFhansen3 7 лет назад

    muy bueno,, go on.

  •  7 лет назад

    Hey, amazing video