I receive a CSV file from a company which I insert into a database. The CSV
has 45 columns/fields in the first row. I would like to know, please, if
anyone can suggest a method which would work better or faster than the one
I'm outlining (in pseudocode) below.

--insert each column/field heading name into an array (strHeading(0), to (44))
--insert data contained in each cell by column into an array
--insert data by row into the database with my array

I will have no problem with the arrays, but as a support to that activity, I
would really like to automate the process of "DIMming" the 45 column heads
according to their respective cell contents so I don't have to do 45 options
in a Select Case statement or something like that.

In other words: (1) I open the CSV file in Word and convert it to a table.
(2) I go from cell to cell in the first row to retrieve the column names.

The column names in the first three cells are Lead_ID, Date, and DataSource.
What I would like to do is DIM a variable per each of these names, for
example, strLead_ID, dtmDate, and strDataSource. I tried the following
without success:

Dim "str" & Selection as String 'throws an error so there's obviously a
concept missing here

Am I on the right track here or do I have to DIM all 45 variables manually?

Also, is there a way to use "range," for example, instead of "Selection" to
determine the contents of a cell? As it is, I go from cell to cell and set
one of the variables equal to the selection. If there is a way of using the
Range attribute, I feel it would tremendously speed up my process as compared
to my present method of using a While to get the content of each cell in a
row by using Selection, then going to the next row until the
Selection.Information(wdWithInTable) = False. It seems like I would do better
to use a Range statement that gets content per
Table(1).Row(intRow).Cell(intCell), but I'm not sure what the exact
statement syntax would be.

Thanks in advance for any help on these two or three task objectives that I
would like to achieve.

--
Bryan

Re: dim variable names for array by Doug

Doug
Thu May 24 04:08:30 CDT 2007

I am not sure what database you are using, but in Access, you could use the
File>Get External Data menu item to do it.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"muyBN" <muyBN@discussions.microsoft.com> wrote in message
news:225BA5C9-523F-4B7B-9795-37161AFC1347@microsoft.com...
>I receive a CSV file from a company which I insert into a database. The CSV
> has 45 columns/fields in the first row. I would like to know, please, if
> anyone can suggest a method which would work better or faster than the one
> I'm outlining (in pseudocode) below.
>
> --insert each column/field heading name into an array (strHeading(0), to
> (44))
> --insert data contained in each cell by column into an array
> --insert data by row into the database with my array
>
> I will have no problem with the arrays, but as a support to that activity,
> I
> would really like to automate the process of "DIMming" the 45 column heads
> according to their respective cell contents so I don't have to do 45
> options
> in a Select Case statement or something like that.
>
> In other words: (1) I open the CSV file in Word and convert it to a table.
> (2) I go from cell to cell in the first row to retrieve the column names.
>
> The column names in the first three cells are Lead_ID, Date, and
> DataSource.
> What I would like to do is DIM a variable per each of these names, for
> example, strLead_ID, dtmDate, and strDataSource. I tried the following
> without success:
>
> Dim "str" & Selection as String 'throws an error so there's obviously a
> concept missing here
>
> Am I on the right track here or do I have to DIM all 45 variables
> manually?
>
> Also, is there a way to use "range," for example, instead of "Selection"
> to
> determine the contents of a cell? As it is, I go from cell to cell and set
> one of the variables equal to the selection. If there is a way of using
> the
> Range attribute, I feel it would tremendously speed up my process as
> compared
> to my present method of using a While to get the content of each cell in a
> row by using Selection, then going to the next row until the
> Selection.Information(wdWithInTable) = False. It seems like I would do
> better
> to use a Range statement that gets content per
> Table(1).Row(intRow).Cell(intCell), but I'm not sure what the exact
> statement syntax would be.
>
> Thanks in advance for any help on these two or three task objectives that
> I
> would like to achieve.
>
> --
> Bryan



Re: dim variable names for array by muyBN

muyBN
Sat May 26 05:09:00 CDT 2007

I am using Access.

I realize that I can go to Access and import a file, but I need to do
everything from Word. My boss, who has to run what I'm developing, is
confused enough working in just one application.

Thanks for your reply, but it doesn't begin to answer the questions I've
posted.

--
Bryan


"Doug Robbins - Word MVP" wrote:

> I am not sure what database you are using, but in Access, you could use the
> File>Get External Data menu item to do it.
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "muyBN" <muyBN@discussions.microsoft.com> wrote in message
> news:225BA5C9-523F-4B7B-9795-37161AFC1347@microsoft.com...
> >I receive a CSV file from a company which I insert into a database. The CSV
> > has 45 columns/fields in the first row. I would like to know, please, if
> > anyone can suggest a method which would work better or faster than the one
> > I'm outlining (in pseudocode) below.
> >
> > --insert each column/field heading name into an array (strHeading(0), to
> > (44))
> > --insert data contained in each cell by column into an array
> > --insert data by row into the database with my array
> >
> > I will have no problem with the arrays, but as a support to that activity,
> > I
> > would really like to automate the process of "DIMming" the 45 column heads
> > according to their respective cell contents so I don't have to do 45
> > options
> > in a Select Case statement or something like that.
> >
> > In other words: (1) I open the CSV file in Word and convert it to a table.
> > (2) I go from cell to cell in the first row to retrieve the column names.
> >
> > The column names in the first three cells are Lead_ID, Date, and
> > DataSource.
> > What I would like to do is DIM a variable per each of these names, for
> > example, strLead_ID, dtmDate, and strDataSource. I tried the following
> > without success:
> >
> > Dim "str" & Selection as String 'throws an error so there's obviously a
> > concept missing here
> >
> > Am I on the right track here or do I have to DIM all 45 variables
> > manually?
> >
> > Also, is there a way to use "range," for example, instead of "Selection"
> > to
> > determine the contents of a cell? As it is, I go from cell to cell and set
> > one of the variables equal to the selection. If there is a way of using
> > the
> > Range attribute, I feel it would tremendously speed up my process as
> > compared
> > to my present method of using a While to get the content of each cell in a
> > row by using Selection, then going to the next row until the
> > Selection.Information(wdWithInTable) = False. It seems like I would do
> > better
> > to use a Range statement that gets content per
> > Table(1).Row(intRow).Cell(intCell), but I'm not sure what the exact
> > statement syntax would be.
> >
> > Thanks in advance for any help on these two or three task objectives that
> > I
> > would like to achieve.
> >
> > --
> > Bryan
>
>
>

Re: dim variable names for array by Doug

Doug
Sat May 26 12:06:02 CDT 2007

Check out the Split() function.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"muyBN" <muyBN@discussions.microsoft.com> wrote in message
news:8690FB85-930C-426F-93C7-6A91270B6765@microsoft.com...
>I am using Access.
>
> I realize that I can go to Access and import a file, but I need to do
> everything from Word. My boss, who has to run what I'm developing, is
> confused enough working in just one application.
>
> Thanks for your reply, but it doesn't begin to answer the questions I've
> posted.
>
> --
> Bryan
>
>
> "Doug Robbins - Word MVP" wrote:
>
>> I am not sure what database you are using, but in Access, you could use
>> the
>> File>Get External Data menu item to do it.
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "muyBN" <muyBN@discussions.microsoft.com> wrote in message
>> news:225BA5C9-523F-4B7B-9795-37161AFC1347@microsoft.com...
>> >I receive a CSV file from a company which I insert into a database. The
>> >CSV
>> > has 45 columns/fields in the first row. I would like to know, please,
>> > if
>> > anyone can suggest a method which would work better or faster than the
>> > one
>> > I'm outlining (in pseudocode) below.
>> >
>> > --insert each column/field heading name into an array (strHeading(0),
>> > to
>> > (44))
>> > --insert data contained in each cell by column into an array
>> > --insert data by row into the database with my array
>> >
>> > I will have no problem with the arrays, but as a support to that
>> > activity,
>> > I
>> > would really like to automate the process of "DIMming" the 45 column
>> > heads
>> > according to their respective cell contents so I don't have to do 45
>> > options
>> > in a Select Case statement or something like that.
>> >
>> > In other words: (1) I open the CSV file in Word and convert it to a
>> > table.
>> > (2) I go from cell to cell in the first row to retrieve the column
>> > names.
>> >
>> > The column names in the first three cells are Lead_ID, Date, and
>> > DataSource.
>> > What I would like to do is DIM a variable per each of these names, for
>> > example, strLead_ID, dtmDate, and strDataSource. I tried the following
>> > without success:
>> >
>> > Dim "str" & Selection as String 'throws an error so there's obviously a
>> > concept missing here
>> >
>> > Am I on the right track here or do I have to DIM all 45 variables
>> > manually?
>> >
>> > Also, is there a way to use "range," for example, instead of
>> > "Selection"
>> > to
>> > determine the contents of a cell? As it is, I go from cell to cell and
>> > set
>> > one of the variables equal to the selection. If there is a way of using
>> > the
>> > Range attribute, I feel it would tremendously speed up my process as
>> > compared
>> > to my present method of using a While to get the content of each cell
>> > in a
>> > row by using Selection, then going to the next row until the
>> > Selection.Information(wdWithInTable) = False. It seems like I would do
>> > better
>> > to use a Range statement that gets content per
>> > Table(1).Row(intRow).Cell(intCell), but I'm not sure what the exact
>> > statement syntax would be.
>> >
>> > Thanks in advance for any help on these two or three task objectives
>> > that
>> > I
>> > would like to achieve.
>> >
>> > --
>> > Bryan
>>
>>
>>