Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default many workbooks in one.

Hi,

I got this code posted on the groups.......

Sub Consolidate()
With Application.FileSearch
.NewSearch
'Change this to your directory
.LookIn = "C:\Excel\delete these"
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
OpenIt = MsgBox("File: " & .FoundFiles(i) & Chr(13) & _
"Do you want to include this?", vbYesNo)
If OpenIt = vbYes Then
Workbooks.Open .FoundFiles(i)
CloseIt = vbNo
If ActiveWorkbook.Worksheets.Count 1 Then
CloseIt = vbYes
Set myBookToClose = ActiveWorkbook
End If
ActiveSheet.Name = Left(ActiveWorkbook.Name, _
Len(ActiveWorkbook.Name) - 4)
ActiveSheet.Move After:=ThisWorkbook.Sheets(1)
If CloseIt = vbYes Then myBookToClose.Close False
End If
Next i
Else: MsgBox "There were no files found."
End If

End With
The problem is that directory is in a intranet using
http://companyname/storesI changed the path and it did not work.. Any
ideas?Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 176
Default many workbooks in one.

Cesar,

That is a copy of my code.

If your are using an intranet, don't use the http: but use the \\
drive designation of the drive/folder, along the lines of -
\\Volume\folder1\folder2\

HTH,
Bernie
MS Excel MVP

"Cesar Zapata" wrote in message
...
Hi,

I got this code posted on the groups.......

Sub Consolidate()
With Application.FileSearch
.NewSearch
'Change this to your directory
.LookIn = "C:\Excel\delete these"
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
OpenIt = MsgBox("File: " & .FoundFiles(i) & Chr(13) & _
"Do you want to include this?", vbYesNo)
If OpenIt = vbYes Then
Workbooks.Open .FoundFiles(i)
CloseIt = vbNo
If ActiveWorkbook.Worksheets.Count 1 Then
CloseIt = vbYes
Set myBookToClose = ActiveWorkbook
End If
ActiveSheet.Name = Left(ActiveWorkbook.Name, _
Len(ActiveWorkbook.Name) - 4)
ActiveSheet.Move After:=ThisWorkbook.Sheets(1)
If CloseIt = vbYes Then myBookToClose.Close False
End If
Next i
Else: MsgBox "There were no files found."
End If

End With
The problem is that directory is in a intranet using
http://companyname/storesI changed the path and it did not work..

Any
ideas?Thanks




Reply
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
Updating Workbooks from multiple links Workbooks TimJames Excel Worksheet Functions 1 December 15th 07 03:34 PM
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
Display 2 formulas from source workbooks to destination workbooks Excel_seek_help Excel Discussion (Misc queries) 4 April 27th 06 08:13 PM
suddenly my excel workbooks are "shared workbooks" Maggie's mom Excel Discussion (Misc queries) 1 August 28th 05 09:20 PM
Workbooks.Open closes other workbooks S. Daum Excel Programming 1 August 21st 03 07:47 PM


All times are GMT +1. The time now is 01:26 AM.

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"