#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default excel 2007

How to change the following macro in order to work in excel 2007:
Sub SearchFiles()

With Application.FileSearch
.NewSearch
.LookIn = "F:\My Documents\"
.SearchSubFolders = True
.Filename = strFileName & ".xls"
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
If LCase(Right(.FoundFiles(i), Len(strFileName & ".xls") + 1)) =
"\" & LCase(strFileName & ".xls") Then
Workbooks.Open .FoundFiles(i), UpdateLinks:=3
Exit For
End If
Next i
Else
'MsgBox "There were no files found."
End If
End With

End Sub


Regards, Pedro
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default excel 2007


Pedro,
XL 2007 was "improved" by removing FileSearch.
Try using the Dir function.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Pedro"
wrote in message
How to change the following macro in order to work in excel 2007:
Sub SearchFiles()

With Application.FileSearch
.NewSearch
.LookIn = "F:\My Documents\"
.SearchSubFolders = True
.Filename = strFileName & ".xls"
.FileType = msoFileTypeExcelWorkbooks
If .Execute() 0 Then
For i = 1 To .FoundFiles.Count
If LCase(Right(.FoundFiles(i), Len(strFileName & ".xls") + 1)) =
"\" & LCase(strFileName & ".xls") Then
Workbooks.Open .FoundFiles(i), UpdateLinks:=3
Exit For
End If
Next i
Else
'MsgBox "There were no files found."
End If
End With

End Sub


Regards, Pedro
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
Format only part of a DataLabel in Excel 2007/PowerPoint 2007 char SamW Charts and Charting in Excel 6 August 16th 09 08:56 PM
Excel 2007 files not showing on screen when opened in Excel 2007 [email protected] Setting up and Configuration of Excel 1 January 8th 09 05:45 PM
Conflict in excel 2007 with Outlook 2007 attachment excel narnimar Excel Discussion (Misc queries) 0 December 17th 08 02:02 PM
Labels: Unable to import all records Excel 2007 to Word 2007 Mailm skelly Excel Discussion (Misc queries) 1 October 29th 08 11:22 PM
Excel 2007 Macro Help (Excel 2003 not working in 2007) Pman Excel Discussion (Misc queries) 4 May 29th 08 06:29 PM


All times are GMT +1. The time now is 03:06 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"