LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #21   Report Post  
Posted to microsoft.public.excel.programming
Sue Sue is offline
external usenet poster
 
Posts: 285
Default Desktop Folder To Workbook

Hi

Just to say many thanks to all now working exactly
as required.
--
Many Thanks

Sue


"Dave Peterson" wrote:

The sfname variable only contains the filename--it doesn't include the path.

Set wbSource = Workbooks.Open(sFname)
should be:
Set wbSource = Workbooks.Open(spath & sFname)

Sue wrote:

Hi
Error Message on Set wbSource line see below!!!

Sub MakeSueA()

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

Const sPATH = "C:\Documents And Settings\Sue\Desktop\CARD\"

Set wbDest = Workbooks.Add

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

Do While Len(sFname) 0
Debug.Print sFname
Set wbSource = Workbooks.Open(sFname) '<<<<<<Message Box: Run-Time 1004 -
OB1.xls could not be found
Debug.Print wbSource.Name
wbSource.Sheets(1).Copy , wbDest.Sheets(wbDest.Sheets.Count)
Debug.Print "Count: " & wbDest.Sheets.Count
wbDest.Sheets(wbDest.Sheets.Count).Name = Replace(wbSource.Name, ".xls", "")
wbSource.Close False
sFname = Dir
Loop

End Sub

As before Immediate Window -- Displays OB1.xls

--
Many Thanks

Sue

"Dick Kusleika" wrote:

On Fri, 20 Feb 2009 12:37:01 -0800, Sue
wrote:


Immediate Window -- Displays OB1.xls

Run 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\Sue\Desktop\CARD\"

Set wbDest = Workbooks.Add

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

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

End Sub

and tell me what the Immediate Window says.
--
Dick


--

Dave Peterson

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Worksheets save new file to Folder on Desktop Jeff[_61_] Excel Programming 2 April 18th 08 09:51 AM
Any problem if i move a shared folder from my desktop to d drive shanavas Excel Discussion (Misc queries) 1 December 16th 07 03:22 PM
Values to a folder name on desktop Matt Excel Discussion (Misc queries) 7 May 15th 06 05:56 PM
Saving a workbook into the desktop Bob Excel Programming 2 April 17th 04 02:45 AM
workbook creates desktop shortcut...HELP daredevil Excel Programming 0 November 13th 03 01:53 AM


All times are GMT +1. The time now is 06:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"