'This will retrieve values from the first 3 lines in an excel file
'The tab is labeled "DATA"
'Then you can assign D1 to the textstring of the attribute.
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_CLOSE = &H10
Function getExcelData() As Collection
Dim xlsFile As String
xlsFile = "c:\test.xls"
Dim ExcelTab As String
ExcelTab = "DATA"
Dim D1, D2, D3
Dim xlWB As Excel.Workbook
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
Dim lngHwnd As Long
lngHwnd = FindWindow("XLMAIN", objExcel.Caption)
Set xlWB = objExcel.Workbooks.Open(Notify:=False, FileName:=xlsFile, Readonly:=True)
For Each item In xlWB.Sheets
If UCase(item.name) = UCase(ExcelTab) Then ' Set the correct sheet
item.Activate
Set app = objExcel.Application.ActiveSheet
D1 = app.Cells(1, 1).value ' get values from the first 3 lines
D2 = app.Cells(2, 1).value
D3 = app.Cells(3, 1).value
Exit For
End If
Next
On Error GoTo theend
xlWB.Close ' Close Sheet
objExcel.Quit ' Try to close Excel
Set objExcel = Nothing ' Clear Reference
SendMessage lngHwnd, WM_CLOSE, 0, 0 ' Force Excel to Close if still open
theend:
End Function
---------------------------
(defun botsbuildbots() (botsbuildbots))