View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Prompt for filename in excel macro VBA

That is not correct, GetOpenFilename doesn't open the file, it just returns
the selected file name.

You need

Dim sFilename as string

sFilename = Application.GetOpenFilename("Excel files (*.xls), *.xls")
If sFilename < "" Then
Workbooks.Open sFilename
End If

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"kdp145" wrote in
message ...

put this after the selection.copy statement

filename = Application.GetOpenFilename("Excel files (*.xls), *.xls")
Windows(filename).Activate

this will prompt the user to select an excel file from the Open file
dialog box and activate whichever file the user selects


--
kdp145
------------------------------------------------------------------------
kdp145's Profile:

http://www.excelforum.com/member.php...o&userid=29594
View this thread: http://www.excelforum.com/showthread...hreadid=521703