VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Simple Code to Call Excel Sheet from VB

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

Rate 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



Download this snippet    Add to My Saved Code

Simple Code to Call Excel Sheet from VB Comments

No comments have been posted about Simple Code to Call Excel Sheet from VB. Why not be the first to post a comment about Simple Code to Call Excel Sheet from VB.

Post your comment

Subject:
Message:
0/1000 characters