Specialized Viewer - Its a challenge for me, how about you? Help Needed

B

Bob

Hello All,

I've been given the task to create a kind of document viewer. The requirements are:

1. A file path & name will be passed to the application. (The file is simply a text file.)
2. The document view will have 3 columns.
3. Headers & Footers required.
4. Columns will be loaded with lines from the text file. (Lines will be loaded into one of the three columns based on codes in the file.)
5. Would like to use the free Word Viewer (WV) if at all possible, otherwise it will be word.

Since I am new to Word VBA I'm looking for advice on how to accomplish the task.

After my limited reading and internet searching I've come up with the following loosely defined plan:

1. From the host application, WV is called with a parameter of the text file name.

2. Upon startup, VBA code will size the page, create appropriate headers and footers and create a three column table. (The reason for using table
rather than just columns is because no snaking of columns is to be done. EG: If there are 160 lines destined for column1 it will be printed over 4
pages (assuming 50 lines per page). If there are only 35 lines in column2, it will be printed on the first page only. Having 403 lines in column3 it
will be spread across 9 pages.

3. VBA Code will read the text file populating the various table columns.

What do you think? Is there an easier way to get this done?

Thanks,

Bob

The layout of the data file is:

$1 <----------- this and following lines go to column 1
data line
data line
data line
data line
$2 <----------- this and following lines go to column 2
data line
data line
data line
data line
$3 <----------- this and following lines go to column 3
data line
data line
data line
eof
 
J

Jay Freedman

Hi Bob,

For starters, you're going to have to use Word, because Word Viewer doesn't
support VBA at all.

Putting the text into a table is definitely the right way to go.

It will probably be more efficient to read the text file twice, first to find
out how many rows you need and then again to fill in the cells after you create
an empty table of the correct size. Adding one row at a time to build up the
table as you fill it would be deadly slow.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.
 

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