|
-
Nov 28th, 2000, 06:00 AM
#1
Thread Starter
Lively Member
hi !
i want to know where i can find information for implemt VB on Excel .
for example :
1. how i connect to the excel file ?
2.how i import the data ?
3.write to the Excel .
4.refer to specific sheet in the *.xls file .
.
.
......
I know how to work with SQl but in this issue i need to work with excel .
so if ytou know on any site ,place ,articals please let me know .
regards ,
-
Nov 28th, 2000, 06:08 AM
#2
Fanatic Member
Look for 'Office Automation' on the Microsoft Web site. Sorry I don't have the exact URL.
Cheers,
P.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Nov 28th, 2000, 08:25 AM
#3
Macro hints
At least for the interacting with excel part....
if you need to figure out how to do something in excel using vb (like centering text or selecting a cell/range etc...) Try recording a macro. Then view the macro. It is not the cleanest way but in most cases you can trim off the extra 'Crap' and use the code you need. I must say though, sometimes this gets frustrating! and as another hint. Whne you come across something like this:
selection.horizontalalignment = xlCenter
the xlCenter (or whatever) has a numeric value. Use the object browser and search for the word. select it, then look at the bottom. The number is displayed.
Using these techniques I was able to make a program that opens a text file....reads all the data in it....sorts it...then dumps it into an excel workbook (containing about 20 sheets) and even make it create charts with specific line color and thickness! I impressed myself! 
Good Luck!!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 28th, 2000, 03:59 PM
#4
Junior Member
Here are the basic commands to get you started. You will need to add the Excel Object library to your project's references.
Code:
Dim ws As Worksheet
Dim sVal As String
Workbooks.Open FileName:="C:\YourFile.xls"
Workbooks.Application.Visible = True
Set ws = ActiveWorkbook.Sheets("Sheet1")
'Get current data from A1
sVal = ws.Range("A1").Text
'Enter new data in A1
ws.Range("A1").FormulaR1C1 = "ABCD"
'Save the file and close Excel
Workbooks.Application.ActiveWorkbook.Save
Workbooks.Application.Quit
Workbooks.Application.DisplayAlerts = False
Hope this helps!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|