Thread: Opening a file
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Opening a file

Dim myFileName as variant
dim FileNum as long

myfilename = application.getopenfilename("Text Files, *.txt")

if myfilename = false then
exit sub 'user hit cancel
end if

filenum = freefile()
open myfilename for input as #filenum





Dan wrote:

Trying to create a macro that prompts the user to open a txt file.

FileName = InputBox("Please enter the Text File's name, e.g. test.txt")
FileNum = FreeFile()
Open FileName For Input As #FileNum

But in place of having them enter the file name, I want to have them browse
for the file then select it. This would be identical to File - Open, and the
Open Browser window appears.

Thanks


--

Dave Peterson