ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Find File (https://www.excelbanter.com/excel-discussion-misc-queries/25307-find-file.html)

GWB Direct

Find File
 
Can I create a macro that would go to the C: Drive and allow me to pick a
file and open it. I want to be able to choose the file after I hit the macro
button.
--
Gary Baker

Nick Hodge

Gary

The code below, throws the standard Open File dialog, allows you to find the
file, clicking OK captures the name in the variable fName, but does not open
it. The next line does that, using the name in the variable to identify the
file to open

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

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"GWB Direct" wrote in message
...
Can I create a macro that would go to the C: Drive and allow me to pick a
file and open it. I want to be able to choose the file after I hit the
macro
button.
--
Gary Baker





All times are GMT +1. The time now is 03:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com