Home All Groups Group Topic Archive Search About

VB to Excel - Best method?

Author
25 Mar 2006 4:58 PM
RonW
Is there a more efficient method of plugging into Excel data that is first
manipulated in a VB6 program? Here's how I'm doing it now:

1. One or more files are opened in VB and the data dumped into a string
2. The data is reformatted (pieces joined together, multiple spaces removed,
etc.) and tabs inserted between "fields" (Each "record" is already terminated
with a CRLF pair)
3. This reformatted string is copied to the clipboard and then pasted into a new
Excel sheet created through automating Excel

This works, but I'm not sure it's the "best" way of doing this. It seems looping
through the string and assigning individual values to Excel cells would be more
work than needed and even less efficient than what I'm doing. The source files
are never really that big, at most maybe 350 - 400K so memory doesn't factor in
as a chokepoint.

I know I can just load the source files straight into Excel (they're nothing
more than text files) but then all the reformatting has to be done in Excel. Not
really an issue but I'm automating the process to make it quicker, and easier
for co-workers.

Short version: Is copying and pasting the way to go here?

Thanks for any insights.

RW

Author
25 Mar 2006 6:03 PM
Schmidt
<RonW@no_domain.invalid> schrieb im Newsbeitrag
news:mcsa22dog8ptu8djr3s5r1q4uuriaag820@4ax.com...

> Short version: Is copying and pasting the way to go here?
It's one way.
Useful are all Methods, wich are transferring the Data into an XL-Range
in one single step (avoiding unnecessary stressing of the X-Process-
marshaled COM-Interface).
You can also use 2dimensional VariantArrays or Recordsets to do
One-Step-Transfers to xl.

Olaf