Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Create and populate an Excel file from Visual Basic6

Posted on 2004-09-29
3
Medium Priority
?
137 Views
Last Modified: 2010-05-02
I need to create an Excel file from Visual Basic, in case the file already exists I need to append from VB. In the Excel file I have two columns I need to populate, First_name and last_name.
How do I do this from Visual Basic, what objects I need to use and what the sysntax might might be?
Thank you
0
Comment
Question by:Mensana
3 Comments
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 12180877
Use .CSV files instead of an Excel .XLS format; both are readable by Excel.

Try:

    Open "x:\mypath\myfile.csv" for output as #1

       For i = Lbound(First_Name()) to Ubound(First_Name())   'or some other loop counter
       
           Print #1, First_name(i) & "," & Last_name(i)
       
       Next i

    Close #1
0
 
LVL 5

Accepted Solution

by:
jkwasson earned 600 total points
ID: 12181133
I agree with jimbob :)

but if, for some reason, you really wanted to use Excel, you would want to add a reference to your vb project for the Microsoft Excel Objects. This would allow you to use the Excel Object Model to control excel from your VB program. You can learn more about it here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wrconExcelObjectModelOverview.asp
0
 
LVL 1

Author Comment

by:Mensana
ID: 12227689
It had to be an Excel file. Thanks for the link. It helped.
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question