Macro to create word doc from batch of TIFs needed (Word 97)

M

Michael Grigoni

Greetings:

Not having VBA experience and imagining that this could be
of use to many, I hope someone could code a macro to create
a Word (97) doc from TIF file batches.

Scanners typically permit simplex batch scanning (sometimes
requiring a 3rd-party app) of TIF images to a directory;
duplex requires flipping the stack and rescanning to a
different directory. The directory structure for a document
would look like this:

DOCROOT
| |
| PREFACE
| | |
| ODD EVEN
| | |
| | |
| 1.TIF |
| 2.TIF |
| ... |
| (n).TIF |
| |
| 1.TIF
| 2.TIF
| ...
| (n).TIF
|
CHAPTER1
| |
ODD EVEN
... ...

where file names are numerically ascending in the ODD subdirectories
and are numerically descending in the EVEN subdirectories.

The macro should be able to traverse the directory tree starting at
a 'chapter' subdirectory and create the document from alternating
insertions of the TIF files, e.g.:
'insert'-> 'picture'->'from file' PREFACE/ODD/1.TIF,
next PREFACE/EVEN/(n).tif, next PREFACE/ODD/2.TIF,
next PREFACE/EVEN/(n-1).TIF... to PREFACE/EVEN/(n).TIF
and then save the document to ../DOC/<chapter dir>.doc, e.g.:
..\doc\preface.doc.

The macro would be manually started in the chapter subdirectory.
No text or other material will be added to the document; it is
solely a collection of TIF images converted to Word.

Useful features would be to sanity check the ODD and EVEN subdirs
for equal number of files and monotonicity of filenames.

Surprisingly I have not found such a macro or other tool to
create Word docs from batch TIF scans; there is an abundance
of PDF assemblers however.

All replies much appreciated.

Michael Grigoni
Cybertheque Museum
 
G

Graham Mayor

It doesn't surprise me there is no such tool.
What you need to do is to create a table that contains a list of the image
files in the order required, then use mail merge to place the images using
your list as a data source.
See http://www.gmayor.com/mail_merge_graphics.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
M

Michael Grigoni

Greetings:

Not having VBA experience and imagining that this could be
of use to many, I hope someone could code a macro to create
a Word (97) doc from TIF file batches.

Like I said, I don't have VBA experience, but I put together
this hack which has saved me countless hours assembling
manuals of hundreds of pages:

Sub assemble()
'
' assemble Macro
' msg 01/18/04
' future enhancements to include auto naming and saving of assembled doc,
' and sanity checking of file names and sequencing of the batches.
Dim n As Integer, m As Integer, nfiles As Integer, fName As String
Dim prefix As String
' variable fName is currently used to hold directory name...
' Set dlg = Dialogs(wdDialogFileOpen)
' aButton = dlg.Display
' fName = dlg.Name
' If aButton = -1 Then
' n = MsgBox("File Selected:" & fName, buttons:=vbOKOnly)
' End If
fName = InputBox("Enter chapter path: ", "Chapter Path")
n = MsgBox("Confirm Chapter Path: " & fName, vbOKCancel)
If n = 1 Then
ChangeFileOpenDirectory (fName)

'I sure would like to find a method to browse and select the directory...
Dialogs(wdDialogFileOpen).Show

nfiles = Val(InputBox("Enter number of files: ", "File Count"))
m = nfiles
For n = 1 To nfiles
If n < 10 Then
prefix = "0"
Else
prefix = ""
End If

Selection.InlineShapes.AddPicture FileName:=fName & _
"\odd\" & prefix & n & ".tif", LinkToFile:= _
False, SaveWithDocument:=True

If m < 10 Then
prefix = "0"
Else
prefix = ""
End If

Selection.InlineShapes.AddPicture FileName:=fName & _
"\even\" & prefix & m & ".tif", LinkToFile:= _
False, SaveWithDocument:=True

m = m - 1
Next n

n = MsgBox("Document Assembled", buttons:=vbOKOnly)
End If
End Sub

Used together with the freeware batch scanning and image viewer
"IrfanView", this code (in Word 97) makes a useful document
scanner and assembler that works with any scanner with a twain
driver and adf.

I would appreciate any help in adding missing features; most
useful would be a method to browse and select the 'chapter'
directory, rather than manually entering it. I call
'Dialogs(wdDialogFileOpen).Show' to permit viewing the
total number of files in a chapter's odd or even subdir;
this number is then input as a count. A useful feature
would be to automatically derive this number.

I hoped to use controls from 'comdlg32.ocx' but get the
following err msg when I try to add these controls to
the toolbox:

"The server application, source file or item cannot be found"

The ActiveX controls were installed with some other app; I
haven't checked the registry.

Michael Grigoni
Cybertheque Museum
 
C

Charles Kenyon

Do you possibly need an OCR application as an intermediate step? If you plan
on editing text from the TIF files, you do.
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
A

administrator

Charles said:
Do you possibly need an OCR application as an intermediate step? If you plan
on editing text from the TIF files, you do.

Reliable OCR would be helpful but for now I am satisfied to have
a viewable Word doc as an alternative to a PDF doc; one can view
the tables of contents and 'go to' page numbers and print. Many
folks scan to PDFs as a way of archiving manuals and other docs
but this requires often high cost converters; doing it in Word
is a low cost option.

I've tried Ominpage Pro 10, Wocar, Xocr, and a bevy of trial
editions of 'high end' ocr packages; one would hope that by
now there would be reliable conversion of single font source
with no embedded graphics (including format retention) but
no such luck for me.

I would appreciate opinions of really good OCR engines for future
consideration.

Michael Grigoni
Cybertheque Museum
 
C

Charles Kenyon

I've been using PaperPort Deluxe (comes with Visioneer scanners) Version 8.
I'm impressed with the OCR in it. Don't know if it has batch capability.
--

Charles Kenyon

Word New User FAQ & Web Directory:
<URL: http://addbalance.com/word/index.htm>

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide)
<URL: http://addbalance.com/usersguide/index.htm>

See also the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
S

Suzanne S. Barnhill

At least one user thinks that ABBYY FineReader is the best OCR app, bar
none, and I believe I have heard that the latest version has a PDF
converter.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Graham Mayor

That would be me :)

Finereader 4 was excellent and as good as any of the current competition.
Finereader 5 set an even more impressive standard for OCR accuracy. The
engine was further improved in Finereader 6 which produced close to 100%
accuracy straight out of the box - and there's a new version 7 I haven't yet
tried :) The corporate version comes with a module for scanning forms, and
the last few versions have been able to handle PDF files.

I too have tried most of the competition, but this one is the best.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top