macro help

R

rkailash

Hi,
I have created a command button in an excel sheet.Now, Im trying to
write a macro code that will help a user to locate a particular file in
the local directories. i.e When a user clicks the button, a browser
window must open up(similar to the 'Save as' button) so that the user
can search through the directories & then select a particular file to
open it.
Could anyone help?
 
N

Nick Hodge

Set you button to run the attached code (Bear in mind there is no
refinement, error checking in this code)

Sub OpenFile()
Dim sfname As String
sfname = Application.GetOpenFilename()
Workbooks.Open Filename:=sfname
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
[email protected]
 
R

rkailash

Thanks Nick.....Its working....

Nick said:
Set you button to run the attached code (Bear in mind there is no
refinement, error checking in this code)

Sub OpenFile()
Dim sfname As String
sfname = Application.GetOpenFilename()
Workbooks.Open Filename:=sfname
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk
[email protected]
 
Top