Solved

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

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no 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…
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…
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…

770 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