View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Copy a Sheet without physically opening the file

Hi Michael

Set Wb2 = Workbooks.Open("C:\test.xls")
You can always use Wb2 in your code to refer to the sheet you have open


Sub test()
Dim Wb1 As Workbook
Dim Wb2 As Workbook
Application.ScreenUpdating = False
Set Wb1 = ActiveWorkbook
Set Wb2 = Workbooks.Open("C:\test.xls")
Wb2.Worksheets(1).copy after:= _
Wb1.Sheets(Wb1.Sheets.Count)
Wb2.Close False
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Michael Kintner" wrote in message ...
Is there a way that I can copy a sheet from one file to the next without
having to use:

Workbooks.Open "Filename", True, True

My problem is I wish to copy Sheet1 from one file to the next, then close
the original file. Currently I can make it work but I do not know how to
get back to the file once I perform the copy sheet command. Note: The
filename may change.

Thank you for your help in advance!!! (smile)

Mike