Sapnapuranic
asked on
References, Components & how to create excel file using Visual basic 6.0
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.
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.
Project- References- Microsoft Excel 8.0 Object Library (EXCEL8.OLB)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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 ~
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 ~
My recommantion: Answered by dhaest
Dim xlSheet
Set xlApp = CreateObject("Excel.Applic
'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