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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The accepted answer links to a question that has been deleted. :-(
Set excel_app = CreateObject("Excel.Applic
excel_app.Workbooks.Open FileName:="C:\emp.xls"
If Val(excel_app.Application.
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.Fre
txtFromVal & " AND " & txtToVal & " FOR " & Opt
excel_sheet.Cells(1, 3).Font.FontStyle = "Bold"