View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default display file open box

Hi fullers, use GetOpenFilename

Sub test()
Dim FName As Variant
Dim wb As Workbook
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = ThisWorkbook.Path
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
If FName < False Then
Set wb = Workbooks.Open(FName)
MsgBox "your code"
wb.Close
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub




--
Regards Ron De Bruin
http://www.rondebruin.nl



"fullers" wrote in message ...
I want a macro that will display the box that allows you to choose a file and
the open it.

When I record the macro I get:

Workbooks.Open Filename:= _
"C:\Documents and Settings\PC User\My Documents\Electricity Bill.xls"

However, I wish the user to be abloe to choose the file and its location
within the box and then continue running the rest of the macro.

How do I do this?

Thanks in advance.