View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Read data from workbook without showing it?

Hi,

This opens a workbook and if it's alraedy open that doesn't cause a problem.
You would need to be more specific if you need help with reading data from
selected sheets

Sub OpenAndDothings()
'Change this to your directory
MyPath = "C:\"
MyFile = "Book3.xls"
Workbooks.Open Filename:=MyPath & MyFile
'Do things
ActiveWorkbook.Close savechanges:=False
End Sub

Mike

"Gustaf" wrote:

How do you load a workbook from VBA, read data from selected sheets and then close it, without it ever showing?

Also, is it necessary to check whether a workbook is already opened before opening it, and closed before closing it?

Many thanks,

Gustaf