| From: Ronit | E-mail: RonitNDM@inter.net.il | 1 |
Date: Saturday, August 25, 2001 at 12:48:13
Subject: Help with writing Macro for excel
Comments:
Hi, I have no experience with Visual Basic but I need help from someone who
has.
I’m a student and I need to complete my C++ project.
I wrote a program in C++ analyzing a special theory.
The outputs of this program are 4 files. 3 ASCCII files and one Excel file
(containing special analyzing program). Each ASCII file contains rows while each
row contains couple of data separated by comma.
I’m interesting in a VB program that will open all of the 4 files.
Load the 3 ASCII files into the Excel file.
From each new Excel file (there are 3 of them), load the second column (in each one there will be only two columns), to a new column in the already exist Excel file (this is the 4th output file that my program created). And close all the output files.
The target is to have in my Excel file (the 4th output of my C++ program) 3 columns with data. While first column will contain the second column of the first converted ASCII file, the second column will contain the second column of the second converted file and the third column will contain the second of the third converted ASCII file.
Thanks in advance.
Regards,
Ronit
| From: Martin Allen | E-mail: <No e-mail> | 2 |
Date: Monday, August 27, 2001 at 15:04:07
Subject: RE: Help with writing Macro for excel
Comments:
First, you need to set a reference to Microsoft Excel 9.0 Object Library by clicking on References on the Project menu. Then put this code in your project e.g. on the convert from CSV to XLS button.
| Workbooks.Open FileName:="C:\WINDOWS\Desktop\Book1.csv" ActiveWorkbook.SaveAs FileName:="C:\WINDOWS\Desktop\Book1.xls", FileFormat _ :=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _ False, CreateBackup:=False Workbooks.Close |
Replace the filenames with ones that are relevant to you. I used Excel to record this macro then copied the code into the Visual Basic 6.0 code window. If you do not know how to write Excel macros, then recording them is the best way to create them.
This forum is no longer taking new messages or replies since 01 November 2002. The above material is for reference purposes only.
The new Visual Basic 6.0 forum can be found here.