Re: Fastest way to read data to populate combo controls?



If it was me, and the Excel File is of moderate size, I would consider
dumping the whole thing into a CSV and parse it using VB. (Not necessarily
the best idea, but I'm simply more confortable with VB.)

When you talk about using a CSV, Ralph, I have no clue how VB would
mass-inport such a file. My idea of importing a CSV into VB would be
to read the file line by line; each line is a string; parse the string
against the commas with SEARCH or FIND and MID. Seems rather
neanderthal - unless this really is the method!! If so, is it really
that efficient?

My Excel data is simply like this:
ColA ColB ColC ColD ColE
F title path comment1 comment2
S title path comment1 comment2
etc ("F" and "S" do not necessarily alternate)

The Excel macro creates a Word document with six tables:

F1:
title path

F2:
com1 path

F3:
com2 path

and three similar for the S files.

The VB app opens the Word doc, iterates the tables and creates six
arrays, then writes these arrays into combos. It works fine. But I
know I tend towards klunky hammer-and-chisel code, and thought I'd
find out if there was a better way to do this.

Ed


On Sep 18, 8:14 am, "Ralph" <nt_consultin...@xxxxxxxxx> wrote:
"Ed from AZ" <prof_ofw...@xxxxxxxxx> wrote in messagenews:9e76767c-1329-4bcf-b428-50a7550666df@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Apologies to Ralph and Lorin for the confusion!  I assure you it is
not limited to names!

The data is simply text strings.  I use a four-column layout in Excel:
-- doc title
-- full path
-- comment 1
-- comment 2

The Excel macro iterates through the used range in Excel and, based on
a designator (F or S) in a fifth column that doesn't get into the
arrays, writes the data into one of six arrays: three F arrays and
three S arrays, with one array of each set having the title and path,
another with comment 1 and path, and the third with comment 2 and
path.  Then the macro creates a Word doc, creates a table for each
array, and writes the array info into the table.

When the VB app opens, the Form.Load opens the WOrd doc, goes through
the tables and re-creates the arrays, then writes these arrays into
combo controls.

==========================================

You lost me. But then I haven't *thought* in Office for a long time.

If it was me, and the Excel File is of moderate size, I would consider
dumping the whole thing into a CSV and parse it using VB. (Not necessarily
the best idea, but I'm simply more confortable with VB.)

[Note: you can write out a csv at any time using ...
 ActiveWorkbook.SaveAs fileFormat:=xlCSV]

You might consider using Automation. Have your VB application open Excel,
mine out the data, creating the Array/s directly in VB. But this again is a
tad slow.

You might rework your Excel Macro (as the logic and work has already been
done) to write to a new work***. Then save that work***.

Can you provide more examples of what the original Excel rows look like and
what the different Fs and Ss are expected to be?

-ralph

.