tweea
Computer
- Mar 29, 2005
- 4
I just started using visual basic and I want to know how to link Excel with visual basic. I created the interface already...I jus need help wit the coding.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
On Error Resume Next 'ignore errors
Set myXL = GetObject(, "Excel.Application") 'look for a running copy
If Err.Number <> 0 Then 'If Excel is not running then
Set myXL = CreateObject("Excel.Application") 'run it
End If
Err.Clear ' Clear Err object in case error occurred.
On Error GoTo 0 'Resume normal error processing
myXL.Workbooks.Open ("c:\j3.xls") ' Your full path
myXL.Visible = True ' or False if you're just processing
myXL.Worksheets(1).Range("J1").Value = "fred" 'set value
lngInput = myXL.Worksheets(1).Range("H2").Value ' get
Dim W As Workbook
For Each W In Workbooks
W.Close savechanges:=False ' or True as reqd
Next W
myXL.Quit
Set myXL = Nothing