View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Deepak Deepak is offline
external usenet poster
 
Posts: 47
Default How to Open txt File and Import it to excel

Hi,

How can I do the following usig VC++ 6.0 SP5 on Excel 2002 ?
The steps I manually perform are as follows. These are the steps I would
like to automate.

1) Launch Excel application
2) File- Open- select/choose a text file.
3) Import into excel - start importing from row 2
4) Set de-limiters for space/tab...etc
5) Run Macro
6) Graph results
7) Save the excel file as a workbook as somename.xls
8) Close the workbook ( which has only one worksheet )
9) Repeat the steps for different files.

I can successfully launch the excel app from my C++ code, which is a direct
rip-off from KB article. I can also launch a FileOpen dialog box. But Im
stuck here. I dont know how to read in the file name. Even if I assume, I can
supply the file names before hand and compile the project, how can I achieve
the rest ?

To elaborate
Say, I have a file a1.txt I need to first do an import into excel, then run
a macro, graph, save as a1.xls or any such name, and close the workbook. and
then open a2.txt , start over again!

Thanks,
Ps: My main problem, is I cant seem to fnid the documentation of the methods
for classes such as _Application, _Workbok..etctec

Deepak