Hi BillCPA,
That did it.
I have been using Set wbxl = CreateObject("Excel.Application") for other
processing, and it has worked fine. In fact, I tried running your code using
CreateObject first (which gave me an error) before I changed it to GetObject.
What is the difference – why does GetObject work but CreateObject does not
in this instance?
I don't know.
This workes for me:
Sub Makro1()
Dim answer As String
Dim oExl As Object
Set oExl = CreateObject("Excel.application")
oExl.Workbooks.Open "c:\test\excel\book1.xls"
Dim Myrange As Object
Set Myrange = oExl.Worksheets("Sheet1").Range("A1:E3")
With oExl
answer = oExl.WorksheetFunction.Min(Myrange)
MsgBox answer
End With
End Sub
As well, this one worked:
Sub Makro1()
Dim answer As String
Dim oExl As Object
Set oExl = GetObject(, "Excel.application")
Dim Myrange As Object
Set Myrange = oExl.Worksheets("Sheet1").Range("A1:E3")
With oExl
answer = oExl.WorksheetFunction.Min(Myrange)
MsgBox answer
End With
End Sub
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Vista Small Business, Office XP