LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to Open excel file when file name is entered in cell

The user specified that the file extensions were .xlsx. That means that there's
a very good chance that the OP is using xl2007.

And filesearch was removed from xl2007.



Spiggy Topes wrote:

Application.FileSearch will do this for you. Lifted almost exactly
from the help sample:

Option Explicit

Private Sub CommandButton1_Click()
Dim fs As FileSearch
Dim i As Integer

Set fs = Application.FileSearch
With fs
.LookIn = "C:\Wherever"
.SearchSubFolders = True
.Filename = Cells(1, 1)
If .Execute() 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub

Opening the file I leave to you, as you didn't say what kind of file
it might be. If it's another Excel workbook ,then
Workbooks.Open .FoundFiles(i)
would do the trick. Otherwise, you could use the ShellExecute API call
to launch the appropriate application for the selected file.


--

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
2007 Macro to Open File, Delete Contents, Save New File Flintstone[_2_] Excel Discussion (Misc queries) 2 February 1st 10 11:25 PM
Open File, pause macro until file is selected Jims Excel Programming 2 December 6th 07 01:34 PM
Open a file do a macro ( made) and open next succesive file SVTman74 Excel Programming 5 April 21st 06 10:14 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


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