Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default PROGRAMMIATICALLY importing CSV data in a SPECIFIC workbook templa

Hi,

I asked this question early but need some clarification. Specifically i'm
trying to programmaticially load CSV data into a specific template-based
workbook without any user interaction.

The opentext method does a good job of this but doesn't have any
functionality to specific a specific workbook to load the data in.

With the workbooks.add method i can specify a specific workbook template,
and then i can execute a macro in that template that will load the data by
opening the csv file and reading line by line, splitting the line on "," and
then output each field into individual cells on a row.

I have some concerns with the performance of this methodology compared with
excel's opentext method. However the OPENTEXT method is probably doing the
same thing that i'm doing so performance wise is it pretty much more the same?

Alternatively i can read in a line, output entire line into 1 cell, then
call range.TextToColumns method but that seems even worse performance wise
because i need to do an extra step to write the line to the cell.

Does anyone have a smarter way programmatically achieving the same function
as OPENTEXT, BUT having the data loaded into a specific workbook template?

Thanks again!
Bing
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default PROGRAMMIATICALLY importing CSV data in a SPECIFIC workbook templa

Have you thought of using workbooks.add to add the workbook based on that
template.

Then open your text file (rename your .csv file to .txt so that you can specify
each column's format), then just copy|paste special|Values into your worksheet
in that new workbook.

You could even do Data|import external data into your workbook (that was based
on the template).

===
If you're data is pretty large, I find that excel's built in OpenText much
faster.


Bing wrote:

Hi,

I asked this question early but need some clarification. Specifically i'm
trying to programmaticially load CSV data into a specific template-based
workbook without any user interaction.

The opentext method does a good job of this but doesn't have any
functionality to specific a specific workbook to load the data in.

With the workbooks.add method i can specify a specific workbook template,
and then i can execute a macro in that template that will load the data by
opening the csv file and reading line by line, splitting the line on "," and
then output each field into individual cells on a row.

I have some concerns with the performance of this methodology compared with
excel's opentext method. However the OPENTEXT method is probably doing the
same thing that i'm doing so performance wise is it pretty much more the same?

Alternatively i can read in a line, output entire line into 1 cell, then
call range.TextToColumns method but that seems even worse performance wise
because i need to do an extra step to write the line to the cell.

Does anyone have a smarter way programmatically achieving the same function
as OPENTEXT, BUT having the data loaded into a specific workbook template?

Thanks again!
Bing


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default PROGRAMMIATICALLY importing CSV data in a SPECIFIC workbook te

Hi Dave,

Thanks for responding.

I have to be able to programmatically do this... ie. no manual intervention,
so not cutting/pasting/etc.

I am using the Workbooks.Add (template) to open the required workbook. Now
i'm trying to AUTOMATICALLY LOAD the data into that workbook. I can't seem
to find a built-in excel function to do this - ie. load the data into the
specified workbook.

The opentext method is great, but you CAN'T specify a workbook template.
OpenText seems to open an blank workbook and loads the data there. Unless i
am mistaken?

"Dave Peterson" wrote:

Have you thought of using workbooks.add to add the workbook based on that
template.

Then open your text file (rename your .csv file to .txt so that you can specify
each column's format), then just copy|paste special|Values into your worksheet
in that new workbook.

You could even do Data|import external data into your workbook (that was based
on the template).

===
If you're data is pretty large, I find that excel's built in OpenText much
faster.


Bing wrote:

Hi,

I asked this question early but need some clarification. Specifically i'm
trying to programmaticially load CSV data into a specific template-based
workbook without any user interaction.

The opentext method does a good job of this but doesn't have any
functionality to specific a specific workbook to load the data in.

With the workbooks.add method i can specify a specific workbook template,
and then i can execute a macro in that template that will load the data by
opening the csv file and reading line by line, splitting the line on "," and
then output each field into individual cells on a row.

I have some concerns with the performance of this methodology compared with
excel's opentext method. However the OPENTEXT method is probably doing the
same thing that i'm doing so performance wise is it pretty much more the same?

Alternatively i can read in a line, output entire line into 1 cell, then
call range.TextToColumns method but that seems even worse performance wise
because i need to do an extra step to write the line to the cell.

Does anyone have a smarter way programmatically achieving the same function
as OPENTEXT, BUT having the data loaded into a specific workbook template?

Thanks again!
Bing


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default PROGRAMMIATICALLY importing CSV data in a SPECIFIC workbook te

Record a macro when you import the data into a separate workbook/worksheet.
Select the usedrange and edit|copy
then go to that new workbook/worksheet and edit|paste special|values
then back to close that other imported text workbook.

You should be able to do this in code:

Option Explicit
Sub testme()

Dim newWks As Worksheet
Dim TextFileName As String
Dim TextWks As Worksheet
Dim TemplateName As String

Application.ScreenUpdating = False

TemplateName = "c:\my documents\excel\book1.xls"
TextFileName = "c:\my documents\excel\spacedelim.txt"

Set newWks = Workbooks.Add(template:=TemplateName).Worksheets(1 )

Workbooks.OpenText Filename:=TextFileName, _
Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, _
Tab:=False, Semicolon:=False, Comma:=False, Space:=True, _
Other:=False, _
FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 1))

Set TextWks = ActiveSheet

TextWks.UsedRange.Copy
newWks.Range("a2").PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False
TextWks.Parent.Close savechanges:=False

Application.ScreenUpdating = True

End Sub

Alternatively, try Data|Import external data (this is the caption in xl2002.
Earlier versions used something else.)

Create a new workbook based on your template
then record a macro when you do the Data|import.



Bing wrote:

Hi Dave,

Thanks for responding.

I have to be able to programmatically do this... ie. no manual intervention,
so not cutting/pasting/etc.

I am using the Workbooks.Add (template) to open the required workbook. Now
i'm trying to AUTOMATICALLY LOAD the data into that workbook. I can't seem
to find a built-in excel function to do this - ie. load the data into the
specified workbook.

The opentext method is great, but you CAN'T specify a workbook template.
OpenText seems to open an blank workbook and loads the data there. Unless i
am mistaken?

"Dave Peterson" wrote:

Have you thought of using workbooks.add to add the workbook based on that
template.

Then open your text file (rename your .csv file to .txt so that you can specify
each column's format), then just copy|paste special|Values into your worksheet
in that new workbook.

You could even do Data|import external data into your workbook (that was based
on the template).

===
If you're data is pretty large, I find that excel's built in OpenText much
faster.


Bing wrote:

Hi,

I asked this question early but need some clarification. Specifically i'm
trying to programmaticially load CSV data into a specific template-based
workbook without any user interaction.

The opentext method does a good job of this but doesn't have any
functionality to specific a specific workbook to load the data in.

With the workbooks.add method i can specify a specific workbook template,
and then i can execute a macro in that template that will load the data by
opening the csv file and reading line by line, splitting the line on "," and
then output each field into individual cells on a row.

I have some concerns with the performance of this methodology compared with
excel's opentext method. However the OPENTEXT method is probably doing the
same thing that i'm doing so performance wise is it pretty much more the same?

Alternatively i can read in a line, output entire line into 1 cell, then
call range.TextToColumns method but that seems even worse performance wise
because i need to do an extra step to write the line to the cell.

Does anyone have a smarter way programmatically achieving the same function
as OPENTEXT, BUT having the data loaded into a specific workbook template?

Thanks again!
Bing


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default PROGRAMMIATICALLY importing CSV data in a SPECIFIC workbook te

Hi Dave,

Thanks for the detailed response. I understand. My requirements are very
intense (i should have pointed this out initially). The data files i am
dealing with have thousands and thousands of lines, each line being a few
hundred characters.. Since i have no control of amount of memory/cpu power
on users computers, i have to refrain from copying large amounts of data to
and from clipboard. Also the data length changes from day to day as well so
a recorded macro may not be too rigid.

I wrote a macro to read line by line using Line Input # VBA statement to
populate worksheet but runs noticeably slower than OPENTEXT. Any ideas?

Thanks again!!
Cheers,
Bing

"Dave Peterson" wrote:

Record a macro when you import the data into a separate workbook/worksheet.
Select the usedrange and edit|copy
then go to that new workbook/worksheet and edit|paste special|values
then back to close that other imported text workbook.

You should be able to do this in code:

Option Explicit
Sub testme()

Dim newWks As Worksheet
Dim TextFileName As String
Dim TextWks As Worksheet
Dim TemplateName As String

Application.ScreenUpdating = False

TemplateName = "c:\my documents\excel\book1.xls"
TextFileName = "c:\my documents\excel\spacedelim.txt"

Set newWks = Workbooks.Add(template:=TemplateName).Worksheets(1 )

Workbooks.OpenText Filename:=TextFileName, _
Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, _
Tab:=False, Semicolon:=False, Comma:=False, Space:=True, _
Other:=False, _
FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 1))

Set TextWks = ActiveSheet

TextWks.UsedRange.Copy
newWks.Range("a2").PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False
TextWks.Parent.Close savechanges:=False

Application.ScreenUpdating = True

End Sub

Alternatively, try Data|Import external data (this is the caption in xl2002.
Earlier versions used something else.)

Create a new workbook based on your template
then record a macro when you do the Data|import.



Bing wrote:

Hi Dave,

Thanks for responding.

I have to be able to programmatically do this... ie. no manual intervention,
so not cutting/pasting/etc.

I am using the Workbooks.Add (template) to open the required workbook. Now
i'm trying to AUTOMATICALLY LOAD the data into that workbook. I can't seem
to find a built-in excel function to do this - ie. load the data into the
specified workbook.

The opentext method is great, but you CAN'T specify a workbook template.
OpenText seems to open an blank workbook and loads the data there. Unless i
am mistaken?

"Dave Peterson" wrote:

Have you thought of using workbooks.add to add the workbook based on that
template.

Then open your text file (rename your .csv file to .txt so that you can specify
each column's format), then just copy|paste special|Values into your worksheet
in that new workbook.

You could even do Data|import external data into your workbook (that was based
on the template).

===
If you're data is pretty large, I find that excel's built in OpenText much
faster.


Bing wrote:

Hi,

I asked this question early but need some clarification. Specifically i'm
trying to programmaticially load CSV data into a specific template-based
workbook without any user interaction.

The opentext method does a good job of this but doesn't have any
functionality to specific a specific workbook to load the data in.

With the workbooks.add method i can specify a specific workbook template,
and then i can execute a macro in that template that will load the data by
opening the csv file and reading line by line, splitting the line on "," and
then output each field into individual cells on a row.

I have some concerns with the performance of this methodology compared with
excel's opentext method. However the OPENTEXT method is probably doing the
same thing that i'm doing so performance wise is it pretty much more the same?

Alternatively i can read in a line, output entire line into 1 cell, then
call range.TextToColumns method but that seems even worse performance wise
because i need to do an extra step to write the line to the cell.

Does anyone have a smarter way programmatically achieving the same function
as OPENTEXT, BUT having the data loaded into a specific workbook template?

Thanks again!
Bing

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default PROGRAMMIATICALLY importing CSV data in a SPECIFIC workbook te

application.screenupdating=false
'do stuff
application.screenupdating=true

you could also check out switching calculation to manual while you're
inporting the data.

Tim.



"Bing" wrote in message
...
Hi Dave,

Thanks for the detailed response. I understand. My requirements are
very
intense (i should have pointed this out initially). The data files
i am
dealing with have thousands and thousands of lines, each line being
a few
hundred characters.. Since i have no control of amount of
memory/cpu power
on users computers, i have to refrain from copying large amounts of
data to
and from clipboard. Also the data length changes from day to day as
well so
a recorded macro may not be too rigid.

I wrote a macro to read line by line using Line Input # VBA
statement to
populate worksheet but runs noticeably slower than OPENTEXT. Any
ideas?

Thanks again!!
Cheers,
Bing

"Dave Peterson" wrote:

Record a macro when you import the data into a separate
workbook/worksheet.
Select the usedrange and edit|copy
then go to that new workbook/worksheet and edit|paste
special|values
then back to close that other imported text workbook.

You should be able to do this in code:

Option Explicit
Sub testme()

Dim newWks As Worksheet
Dim TextFileName As String
Dim TextWks As Worksheet
Dim TemplateName As String

Application.ScreenUpdating = False

TemplateName = "c:\my documents\excel\book1.xls"
TextFileName = "c:\my documents\excel\spacedelim.txt"

Set newWks =
Workbooks.Add(template:=TemplateName).Worksheets(1 )

Workbooks.OpenText Filename:=TextFileName, _
Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, _
Tab:=False, Semicolon:=False, Comma:=False, Space:=True, _
Other:=False, _
FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 1))

Set TextWks = ActiveSheet

TextWks.UsedRange.Copy
newWks.Range("a2").PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False
TextWks.Parent.Close savechanges:=False

Application.ScreenUpdating = True

End Sub

Alternatively, try Data|Import external data (this is the caption
in xl2002.
Earlier versions used something else.)

Create a new workbook based on your template
then record a macro when you do the Data|import.



Bing wrote:

Hi Dave,

Thanks for responding.

I have to be able to programmatically do this... ie. no manual
intervention,
so not cutting/pasting/etc.

I am using the Workbooks.Add (template) to open the required
workbook. Now
i'm trying to AUTOMATICALLY LOAD the data into that workbook. I
can't seem
to find a built-in excel function to do this - ie. load the data
into the
specified workbook.

The opentext method is great, but you CAN'T specify a workbook
template.
OpenText seems to open an blank workbook and loads the data
there. Unless i
am mistaken?

"Dave Peterson" wrote:

Have you thought of using workbooks.add to add the workbook
based on that
template.

Then open your text file (rename your .csv file to .txt so that
you can specify
each column's format), then just copy|paste special|Values into
your worksheet
in that new workbook.

You could even do Data|import external data into your workbook
(that was based
on the template).

===
If you're data is pretty large, I find that excel's built in
OpenText much
faster.


Bing wrote:

Hi,

I asked this question early but need some clarification.
Specifically i'm
trying to programmaticially load CSV data into a specific
template-based
workbook without any user interaction.

The opentext method does a good job of this but doesn't have
any
functionality to specific a specific workbook to load the
data in.

With the workbooks.add method i can specify a specific
workbook template,
and then i can execute a macro in that template that will
load the data by
opening the csv file and reading line by line, splitting the
line on "," and
then output each field into individual cells on a row.

I have some concerns with the performance of this methodology
compared with
excel's opentext method. However the OPENTEXT method is
probably doing the
same thing that i'm doing so performance wise is it pretty
much more the same?

Alternatively i can read in a line, output entire line into 1
cell, then
call range.TextToColumns method but that seems even worse
performance wise
because i need to do an extra step to write the line to the
cell.

Does anyone have a smarter way programmatically achieving the
same function
as OPENTEXT, BUT having the data loaded into a specific
workbook template?

Thanks again!
Bing

--

Dave Peterson


--

Dave Peterson



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default PROGRAMMIATICALLY importing CSV data in a SPECIFIC workbook te

Hi Tim,

Did that. Can you elaborate on what you are refering to my "switching
calculation to manual"?

Thanks for responding!
Cheers,
Bing

"Tim Williams" wrote:

application.screenupdating=false
'do stuff
application.screenupdating=true

you could also check out switching calculation to manual while you're
inporting the data.

Tim.



"Bing" wrote in message
...
Hi Dave,

Thanks for the detailed response. I understand. My requirements are
very
intense (i should have pointed this out initially). The data files
i am
dealing with have thousands and thousands of lines, each line being
a few
hundred characters.. Since i have no control of amount of
memory/cpu power
on users computers, i have to refrain from copying large amounts of
data to
and from clipboard. Also the data length changes from day to day as
well so
a recorded macro may not be too rigid.

I wrote a macro to read line by line using Line Input # VBA
statement to
populate worksheet but runs noticeably slower than OPENTEXT. Any
ideas?

Thanks again!!
Cheers,
Bing

"Dave Peterson" wrote:

Record a macro when you import the data into a separate
workbook/worksheet.
Select the usedrange and edit|copy
then go to that new workbook/worksheet and edit|paste
special|values
then back to close that other imported text workbook.

You should be able to do this in code:

Option Explicit
Sub testme()

Dim newWks As Worksheet
Dim TextFileName As String
Dim TextWks As Worksheet
Dim TemplateName As String

Application.ScreenUpdating = False

TemplateName = "c:\my documents\excel\book1.xls"
TextFileName = "c:\my documents\excel\spacedelim.txt"

Set newWks =
Workbooks.Add(template:=TemplateName).Worksheets(1 )

Workbooks.OpenText Filename:=TextFileName, _
Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, _
Tab:=False, Semicolon:=False, Comma:=False, Space:=True, _
Other:=False, _
FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 1))

Set TextWks = ActiveSheet

TextWks.UsedRange.Copy
newWks.Range("a2").PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False
TextWks.Parent.Close savechanges:=False

Application.ScreenUpdating = True

End Sub

Alternatively, try Data|Import external data (this is the caption
in xl2002.
Earlier versions used something else.)

Create a new workbook based on your template
then record a macro when you do the Data|import.



Bing wrote:

Hi Dave,

Thanks for responding.

I have to be able to programmatically do this... ie. no manual
intervention,
so not cutting/pasting/etc.

I am using the Workbooks.Add (template) to open the required
workbook. Now
i'm trying to AUTOMATICALLY LOAD the data into that workbook. I
can't seem
to find a built-in excel function to do this - ie. load the data
into the
specified workbook.

The opentext method is great, but you CAN'T specify a workbook
template.
OpenText seems to open an blank workbook and loads the data
there. Unless i
am mistaken?

"Dave Peterson" wrote:

Have you thought of using workbooks.add to add the workbook
based on that
template.

Then open your text file (rename your .csv file to .txt so that
you can specify
each column's format), then just copy|paste special|Values into
your worksheet
in that new workbook.

You could even do Data|import external data into your workbook
(that was based
on the template).

===
If you're data is pretty large, I find that excel's built in
OpenText much
faster.


Bing wrote:

Hi,

I asked this question early but need some clarification.
Specifically i'm
trying to programmaticially load CSV data into a specific
template-based
workbook without any user interaction.

The opentext method does a good job of this but doesn't have
any
functionality to specific a specific workbook to load the
data in.

With the workbooks.add method i can specify a specific
workbook template,
and then i can execute a macro in that template that will
load the data by
opening the csv file and reading line by line, splitting the
line on "," and
then output each field into individual cells on a row.

I have some concerns with the performance of this methodology
compared with
excel's opentext method. However the OPENTEXT method is
probably doing the
same thing that i'm doing so performance wise is it pretty
much more the same?

Alternatively i can read in a line, output entire line into 1
cell, then
call range.TextToColumns method but that seems even worse
performance wise
because i need to do an extra step to write the line to the
cell.

Does anyone have a smarter way programmatically achieving the
same function
as OPENTEXT, BUT having the data loaded into a specific
workbook template?

Thanks again!
Bing

--

Dave Peterson


--

Dave Peterson




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 733
Default PROGRAMMIATICALLY importing CSV data in a SPECIFIC workbook te

"Bing" wrote...
. . . Can you elaborate on what you are refering to my "switching
calculation to manual"?


See Application.Calculation in Excel/VBA online help.


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default PROGRAMMIATICALLY importing CSV data in a SPECIFIC workbook te

Well, you could test it manually before you develop the code.

Try importing the text using File|open and then copy|paste to the other sheet.

I'd be very surprised if this is slower than pasing the data in code. And
copy|pasting plain old text shouldn't be too much of a drag on any system (I use
a 400 mhz, win98SE pc at home!).

But the only really sure way to know is to try it and see.



Bing wrote:

Hi Dave,

Thanks for the detailed response. I understand. My requirements are very
intense (i should have pointed this out initially). The data files i am
dealing with have thousands and thousands of lines, each line being a few
hundred characters.. Since i have no control of amount of memory/cpu power
on users computers, i have to refrain from copying large amounts of data to
and from clipboard. Also the data length changes from day to day as well so
a recorded macro may not be too rigid.

I wrote a macro to read line by line using Line Input # VBA statement to
populate worksheet but runs noticeably slower than OPENTEXT. Any ideas?

Thanks again!!
Cheers,
Bing

"Dave Peterson" wrote:

Record a macro when you import the data into a separate workbook/worksheet.
Select the usedrange and edit|copy
then go to that new workbook/worksheet and edit|paste special|values
then back to close that other imported text workbook.

You should be able to do this in code:

Option Explicit
Sub testme()

Dim newWks As Worksheet
Dim TextFileName As String
Dim TextWks As Worksheet
Dim TemplateName As String

Application.ScreenUpdating = False

TemplateName = "c:\my documents\excel\book1.xls"
TextFileName = "c:\my documents\excel\spacedelim.txt"

Set newWks = Workbooks.Add(template:=TemplateName).Worksheets(1 )

Workbooks.OpenText Filename:=TextFileName, _
Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, _
Tab:=False, Semicolon:=False, Comma:=False, Space:=True, _
Other:=False, _
FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
Array(7, 1), Array(8, 1), Array(9, 1))

Set TextWks = ActiveSheet

TextWks.UsedRange.Copy
newWks.Range("a2").PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False
TextWks.Parent.Close savechanges:=False

Application.ScreenUpdating = True

End Sub

Alternatively, try Data|Import external data (this is the caption in xl2002.
Earlier versions used something else.)

Create a new workbook based on your template
then record a macro when you do the Data|import.



Bing wrote:

Hi Dave,

Thanks for responding.

I have to be able to programmatically do this... ie. no manual intervention,
so not cutting/pasting/etc.

I am using the Workbooks.Add (template) to open the required workbook. Now
i'm trying to AUTOMATICALLY LOAD the data into that workbook. I can't seem
to find a built-in excel function to do this - ie. load the data into the
specified workbook.

The opentext method is great, but you CAN'T specify a workbook template.
OpenText seems to open an blank workbook and loads the data there. Unless i
am mistaken?

"Dave Peterson" wrote:

Have you thought of using workbooks.add to add the workbook based on that
template.

Then open your text file (rename your .csv file to .txt so that you can specify
each column's format), then just copy|paste special|Values into your worksheet
in that new workbook.

You could even do Data|import external data into your workbook (that was based
on the template).

===
If you're data is pretty large, I find that excel's built in OpenText much
faster.


Bing wrote:

Hi,

I asked this question early but need some clarification. Specifically i'm
trying to programmaticially load CSV data into a specific template-based
workbook without any user interaction.

The opentext method does a good job of this but doesn't have any
functionality to specific a specific workbook to load the data in.

With the workbooks.add method i can specify a specific workbook template,
and then i can execute a macro in that template that will load the data by
opening the csv file and reading line by line, splitting the line on "," and
then output each field into individual cells on a row.

I have some concerns with the performance of this methodology compared with
excel's opentext method. However the OPENTEXT method is probably doing the
same thing that i'm doing so performance wise is it pretty much more the same?

Alternatively i can read in a line, output entire line into 1 cell, then
call range.TextToColumns method but that seems even worse performance wise
because i need to do an extra step to write the line to the cell.

Does anyone have a smarter way programmatically achieving the same function
as OPENTEXT, BUT having the data loaded into a specific workbook template?

Thanks again!
Bing

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
importing specific data into a new excel spreadsheet AllieR Excel Discussion (Misc queries) 3 January 18th 09 08:16 PM
Importing data from access to excel to a specific columns ielmrani via OfficeKB.com Links and Linking in Excel 1 September 24th 08 09:52 AM
importing specific cells from multiple workbooks into 1 workbook Walter Davis New Users to Excel 5 June 18th 08 04:15 AM
Importing specific data into an Excel workbook kare9 Excel Worksheet Functions 1 January 6th 07 06:39 PM
Importing data into specific template cells Ron Excel Discussion (Misc queries) 0 July 11th 06 07:24 PM


All times are GMT +1. The time now is 07:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"