Solved

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

Posted on 2003-11-04
8
135 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

747 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

12 Experts available now in Live!

Get 1:1 Help Now