by Raghuraja. C (21 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 20th June 2003
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
Simple Code to Call Excel Sheet from VB
Dim objBook As Excel.Workbook
Dim objSheet As Excel.Worksheet
Dim fName As String
Set objExcel = New Excel.Application
'Another Method to create Excel Object
'Set objExcel = CreateObject("Excel.application")
fName = AppPath() + "Excel Example"
Set objBook = objExcel.Workbooks.Open(fName)
Set Sheet = objBook.Worksheets(1)
Sheet.Range("B8", "B18").Font.Bold = True 'To Set Bold Font
Sheet.Range("A1").Value = "This is A1 Cell"
Sheet.Range("B1").Value = "This is B1 Cell"
Sheet.Range("C1").Value = "This is C1 Cell"
Sheet.Range("D1").Value = "This is D1 Cell"
Sheet.Range("E1").Value = "This is E1 Cell"
objExcel.Visible = True
objExcel.UserControl = True
objExcel.Caption = "Excel Report Example"
objExcel.DisplayExcel4Menus = False