macro help

  • Thread starter Thread starter rkailash
  • Start date Start date
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?
 
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
(e-mail address removed)
 
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
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top