Hi guys, really hope someone can help with this problem as it's driving me insane!
I currently have a VBA code that will open a TIFF file and then copy all the text detected within the TIFF file into a standard text file which is done using OCR as it's a TIFF image file.
This works great but need to take it one step further but I'm struggling at the moment.
Within the TIFF file there is a 6 digit reference number that is contained within the first 2 sentances of the text. I need VBA to rename the filename of the TIFF file with this 6 digit reference number, and then repeat the process for every TIFF file within the folder and also the sub-folders.
Does anyone have any ideas how I can change the code below to do what I need it to do?
Hope you can help, you're my only hope!
Many thanks in advance,
Dave
Here's the code I'm using but please be aware I could only get it to work by selecting 'Microsoft Office Document Imaging 11.0 Type Library' from Tools>References Menu in Excel VBA and I don't think this option is available in any of the more recent versions of Excel (i'm using Excel 2003)
Really hope you can help, I'm so close to getting this nailed.
Sub RenameTIFF()
Dim doc1 As MODI.Document
Dim inputFile As String
Dim strRecText As String
Dim imageCounter As Integer
inputFile = Application.GetOpenFilename
strRecText = ""
Set doc1 = New MODI.Document
doc1.Create (inputFile)
doc1.OCR
For imageCounter = 0 To (doc1.Images.Count - 1)
strRecText = strRecText & doc1.Images(imageCounter).Layout.Text
Next
fnum = FreeFile()
Open "C:\TEMP\testmodi.txt" For Output As fnum
Print #fnum, strRecText
Close #fnum
doc1.Close
End Sub
I currently have a VBA code that will open a TIFF file and then copy all the text detected within the TIFF file into a standard text file which is done using OCR as it's a TIFF image file.
This works great but need to take it one step further but I'm struggling at the moment.
Within the TIFF file there is a 6 digit reference number that is contained within the first 2 sentances of the text. I need VBA to rename the filename of the TIFF file with this 6 digit reference number, and then repeat the process for every TIFF file within the folder and also the sub-folders.
Does anyone have any ideas how I can change the code below to do what I need it to do?
Hope you can help, you're my only hope!
Many thanks in advance,
Dave
Here's the code I'm using but please be aware I could only get it to work by selecting 'Microsoft Office Document Imaging 11.0 Type Library' from Tools>References Menu in Excel VBA and I don't think this option is available in any of the more recent versions of Excel (i'm using Excel 2003)
Really hope you can help, I'm so close to getting this nailed.
Sub RenameTIFF()
Dim doc1 As MODI.Document
Dim inputFile As String
Dim strRecText As String
Dim imageCounter As Integer
inputFile = Application.GetOpenFilename
strRecText = ""
Set doc1 = New MODI.Document
doc1.Create (inputFile)
doc1.OCR
For imageCounter = 0 To (doc1.Images.Count - 1)
strRecText = strRecText & doc1.Images(imageCounter).Layout.Text
Next
fnum = FreeFile()
Open "C:\TEMP\testmodi.txt" For Output As fnum
Print #fnum, strRecText
Close #fnum
doc1.Close
End Sub