How can Vb6 read from an Excel file and store the data in an Array with two dimensions. The data from cell A1 to store in Arrays a11 , the cell B1 to store in a12 the A2 to store in a21 the
cell B2 to store in a22 etc.
Also how can write to an Excel file from An Array With two dimensions and the data to go to the excel file as above
a11 to cell A1 , a12 to cell B1, a21 to cell A2, a22 to cell B2 etc
Unfortunately didnot work
Reads Cells A1 to E10 into a(1,1) to a(10,5)
Writes a(1,1) to a(10,5) into Cells A1 to E10
Both give "Expected: end of Statement"
And when I had tried to run the program
Dim xlApp As Excel.Application gave "User -defined type not defined.
Oh, sorry, I forget to put the use the coment marks for the Read and Write line, also forget the reference to Excel.
That happens if you try to help, when your not on your programming computer! sorry
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry!
When you have a project, you can follow these directions to reference Excel/Office Libraries:
1) While inside the project, on the top menu, click Project and go to the bottom where it says References... and click that.
2) Once in the references, scroll down until you get to:
Microsoft Office X.X Object Libray and put a check in the box
beside it. Note: X.X is version number like 10.0 or 9.0
That is all you have to do to reference Excel/Office. If you need more help, let me know. HTH, Jeremy
When in the IDE, open the menu Project and References (i hope it'S the correct english name for that, it'as the third from the bottom). In the opening window you can select the checkmark next to the MS EXCEL Object libary.
That's it!
Dammed too slow!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry!
opus and JCScoobyRS Thank you very much .Now the program is working perfectly. During writing in the output Excel file if i want to
save changes with out asking me if i want to save changes what I have to add in the program?
I tried to use the same way to Export some data from VB apps to Excel file, but I encounter one weird problem. That's is, you must exit your VB application first (or unload the form) before you can open up the Excel file just exported from your applications.
anybody knows the reason behind this? and what is the work around for this??
I tried to use that objExcel.Visible = True. The outcome is the same. When I lauched the Excel while my Vb apps is still on, the Excel is running fine, but the "Workbook" sub-form just stuck there, I can not see the workbook exported from the VB apps. Both objExcel.Visible = True or lauching applications manually give the same result. I tried to run it on other PC, the result still the same.
I herewith attached the file for your reference. Apparently, this sample VB apps (i download it some where) unload the form to make it works.
From looking at your project...I'd create a template Excel file and open it in code instead of creating a new one. It's easier to deal with and manage. I have posted code earlier in this thread with instructions and code. If you'd like more help, let me know. Thanks, Jeremy
Just so you know though...I just ran your program and it created the Excel file and showed it to me. Kind of wierd. So when you click all the buttons in your program, the Excel object isn't visible or the worksheet isn't visible or what? HTH, Jeremy