Solved

References, Components & how to create excel file using Visual basic 6.0

Posted on 2003-11-04
8
136 Views
Last Modified: 2010-08-05
Hello Experts,
  I am trying to create an excel file using createobject.
but when i type excel , its not available in the list & doesn't list the objects / properties.i think i have missed adding a reference / component. can any one tell what are the references & components required for creating word/ excel files. & how do we statrt working on it.
0
Comment
Question by:Sapnapuranic
  • 3
8 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 9684839
Dim xlApp
Dim xlSheet

Set xlApp = CreateObject("Excel.Application")
'xlApp.Visible = True
xlApp.Workbooks.Add
Set xlSheet = xlApp.ActiveSheet

xlSheet.Name = "My Sheet1"
'Header row
xlSheet.Cells(1, 1) = "Product Name" 'meaning Row=1 Column=1
xlSheet.Cells(1, 2).Value = "Barcode"  'meaning Row=1 Column=2
'............
'............
'Row = 200, Column = 5 that is where your formula can be
xlSheet.Cells(200, 5).FormulaR1C1 = "=Sum(R2C5:R199C5)"

xlSheet.SaveAs "C:\My Sheet.xls"
xlApp.quit
Set xlSheet = Nothing
Set xlApp = Nothing
0
 
LVL 2

Expert Comment

by:specialfreckles
ID: 9684867
Project- References- Microsoft Excel 8.0 Object Library (EXCEL8.OLB)
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 20 total points
ID: 9684887
"Project- References- Microsoft Excel 8.0 Object Library (EXCEL8.OLB) "
--> depends of your version of office (office 97, 2000, xp, 2003, ...)
With the example i've send, you don't need any reference
0
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9685696
There are two way of using reference to Office by automation.
1) using the CreateObject method -> this however will not show the method/properties of the object
2) by reference-> goto Project>References to add reference

~ fantasy ~
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 10163182
My recommantion: Answered by dhaest
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

912 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now