Solved

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

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

840 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