473,327 Members | 1,930 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

what is the difference loading excel using msflexgrid or OLE

hallo sir .. i am still new on using vb and i have tried to load an excel using a visual basic interface.. but if i wanted to plot my excel data what should i do.. must i cahnge my program on loading the excel by using OLE or Msflexgrid.. i am very confuse..hope u can give me some tip on how should i plot my graph using the visual basci interface. here i gave my program:

Option Explicit
Dim Excel As Object
Dim ExcelSheet As Object
Dim Workbooks As Object
Private Sub CmdLoad_Click()
Dim i As Long
Dim n As Long
Set Excel = Nothing
Set ExcelSheet = Nothing
Set Workbooks = Nothing
Dim filename As String
filename = Dir1.Path & "\" & File1.filename
On Error Resume Next
Set Excel = GetObject(, "Excel.Application")
If Err <> 0 Then
Err.Clear
Set Excel = CreateObject("Excel.Application")
If Err <> 0 Then
MsgBox "Could Not load Excel.", vbExclamation
End
End If
End If
Excel.Visible = True ' show the excel screen
Excel.Workbooks.Open filename ' open the selected or mentioned file
Set ExcelSheet = Excel.ActiveWorkbook.Sheets(1) ' open the first sheet in the workbook

With MSFlexGrid1
.Cols = 10
.Rows = 110
For i = 0 To .Rows - 1
.Row = i
For n = 0 To .Cols - 1
.Col = n
.Text = ExcelSheet.Cells(i + 1, n + 1).Value
Next
Next
End With
End Sub


Private Sub CmdClose_Click()
Unload Me
End Sub

Private Sub File1_Click()
Label2.Caption = Dir1.Path & "\" & File1.filename ' display the current path and file name in the label2.caption which is present at the bottom of the form
End Sub

Private Sub File1_DblClick()
Call CmdLoad_Click 'if the user double clicks the mouse by selecting the file
End Sub

Private Sub File1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Call Command1_Click ' if the user presses enter key by selecting the file
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then Unload Me
End Sub


Private Sub Dir1_Change()
Label2.Caption = Dir1.Path ' display the current directory path
File1.Path = Dir1.Path ' change the file path with relevant to the directory path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive ' change the directory path relevant to the drive path
End Sub

Private Sub Form_Load()
File1.Pattern = "*.xls" ' set the filelist box to open only the files which has extension .xls
Dir1.Path = Left(Environ("dir"), 3) & ""
End Sub
Sep 11 '07 #1
0 1892

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ?rjan | last post by:
Hi ! I have a MSFlexgrid control in a form (much like a calender) When I try to export this to excel by using code (excel.application etc) I cant get the colors right !?! Ex. I have a...
1
by: PVS | last post by:
Hi, I am new to VC++ 7.0. I want to use MSFlexGrid in my dialog based MFC project in VC++ 7.0 (in VS ..NET IDE). I added the MSFlexGrid control into my resource editor toolbox and I dragged and...
1
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
0
by: Steven | last post by:
Hi All, Is there any method to copy the MSFlexGrid data (including the text color, cell background color etc) to the microsoft excel work sheet? By using the clipboard function, I can read the...
2
by: uprakash14 | last post by:
i want to get excel data in datagrid or msflexgrid... gve me some hints '
5
by: sansann | last post by:
Hello there! i need help on loading data from my Access database query table name combine into my MSFlexgrid select by batchno category. when i runn below coding the error said "Selected collating...
5
by: Ishmael | last post by:
Hi Is Been a 3 Yrs Now (I Still trying to do this) Please help me to do this with Visual Basic 6.0 using Msflexgrid Let say you are the Principal . You have 10 educators and 5 class (Grades)...
4
by: MiziaQ | last post by:
Hey. I have a problem. I am entering data into various textboxes and writing it to a file. I then reading that data in a MSFlexGrid table. I have no problem with that. The only problem is that when...
0
by: mahesh123 | last post by:
Hi Folks, How can i export the data from the MSFlexGrid to the MS Open Office Excel in VB 6.0? I Can Know how to export data from the MSFlexgrid to the MS Office Excel. Please Help me regarding...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.