Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default display file open box

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
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.



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
excel file seems to open but does not display neilc Excel Discussion (Misc queries) 2 August 13th 09 06:52 PM
open csv file, display format kei Excel Discussion (Misc queries) 2 January 23rd 06 09:57 AM
Open an excel file but it does not display Fred Zack Excel Discussion (Misc queries) 3 December 21st 05 06:45 PM
How do I display each Excel file I open in the task bar bocjoel Excel Discussion (Misc queries) 3 September 28th 05 08:04 PM
How to display an open file? jose luis Excel Programming 0 July 6th 05 06:40 PM


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