Link to home
Start Free TrialLog in
Avatar of ryanlam2k3
ryanlam2k3

asked on

VB Form operate with Excel

I want to know that how does Visual Basic form work with Excel. My idea is that I use VB from to get some staistic data from DataBase. After this, VB from will pass data to Excel to plot a graph, like bar chat...etc. Finally, the result of Excel will be shown on VB form. However, I don't know how can I do this. Please Help me with example coding. Thanks a lot
Avatar of sudipta_pal
sudipta_pal

 try this type of code write in the Excel


  Set excel_app = CreateObject("Excel.Application")
    excel_app.Workbooks.Open FileName:="C:\emp.xls"
    If Val(excel_app.Application.Version) >= 8 Then
        Set excel_sheet = excel_app.ActiveSheet
    Else
        Set excel_sheet = excel_app
    End If
for i roww = 1 to 40

for colmn = 1 to 40
   excel_sheet.Cells(roww, colmn).Font.Color = RGB(0, 0, 0)
   excel_sheet.Cells(roww, colmn) = ""
   excel_sheet.Cells(roww, colmn).Font.Size = 8
  excel_sheet.Cells(roww, colmn).Font.FontStyle = "Regular"
 next
next  
     
     excel_sheet.Cells(6, 1) = "CODE"
     excel_sheet.Cells(6, 2) = "NAME"
     excel_sheet.Rows(5).Select
     excel_app.ActiveWindow.FreezePanes = False

    txtFromVal & " AND " & txtToVal & "  FOR  " & Opt
      excel_sheet.Cells(1, 3).Font.FontStyle = "Bold"
ASKER CERTIFIED SOLUTION
Avatar of Minutes
Minutes

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tim Bouscal
The accepted answer links to a question that has been deleted.  :-(