>Hi,
>
>i've try and successful to use getobject function to get the data from excel file. But i must open excel before running this function , if not, error will occurs!
>
>My coding:
> ' VpurBOM is a listbox
> Dim pur_xls As Object
> Set pur_xls = GetObject(VpurBOM.List(0))
> pur_xls.Application.Visible = False
> pur_xls.Parent.Windows(1).Visible = False
>
> ' test part
> MsgBox pur_xls.Worksheets("sheet1").Range("A1").Value
> ' end test part
>
> If findwindow("XLMAIN", 0) <> 0 Then
> pur_xls.Application.Quit
> End If
>
>"findwindow" is a function use API to find whether excel program is running or not~!
>
>Is that the problem i set the "application.visible = False" ?!
I don't have this problem! When I try your code snippet, Excel is launched with the workbook inside. I have now Excel 97.
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com