View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Desktop Folder To Workbook

Hi

I did exactly as you told me in your latest post -- changed the path to the
correct one and had the same result New workbook opened but nothing from the
desktop folder CARD


--
Many Thanks

Sue


"Dick Kusleika" wrote:

On Thu, 19 Feb 2009 07:45:04 -0800, Sue
wrote:

Hi

I noticed that before I posted and changed the path to the correct folder on
the desk top.

I apologise for being such a pain in the you know what - however your help
is very much appreciated.


No problem Sue. We're missing something simple, we just need to figure out
what it is. So it's not even copying the files. This next test is a bit
dangerous, so save any open files and close them before running this.


Sub MakeSue()

Dim wbDest As Workbook
Dim wbSource As Workbook
Dim sh As Worksheet
Dim sFname As String

Const sPATH = "C:\Documents and Settings\Dick\Desktop\CARD\"

Set wbDest = Workbooks.Add

sFname = Dir(sPATH & "*.*")

Do While Len(sFname) 0
Debug.Print sFname
Set wbSource = Workbooks.Open(sFname)
wbSource.Sheets(1).Copy , wbDest.Sheets(wbDest.Sheets.Count)
wbDest.Sheets(wbDest.Sheets.Count).Name = Replace(wbSource.Name,
".xls", "")
wbSource.Close False
sFname = Dir
Loop

End Sub

This one will open every file in that folder, even non-Excel ones. Tell me
what you get - results or errors.
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com