ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Browse for file name code? (Excel 2002 VBA) (https://www.excelbanter.com/excel-programming/359910-browse-file-name-code-excel-2002-vba.html)

[email protected]

Browse for file name code? (Excel 2002 VBA)
 
Hello. I need to create a macro that displays a browser window, lets
the user choose a folder and then a filename within the folder, and
updates all the links in the file to that found file. I wrote the code
that updates the links but I am struggling creating code that lets the
user choose the folder and filename. Searching around I found the
following code. It works wonderfully allowing the user to select a
folder. But how do I make it display the filenames within a folder and
let the user select one? Thanks for any help!
http://www.cpearson.com/excel/BrowseFolder.htm


AA2e72E

Browse for file name code? (Excel 2002 VBA)
 
application.Dialogs(xlDialogFindFile).Show
might be what you need.

" wrote:

Hello. I need to create a macro that displays a browser window, lets
the user choose a folder and then a filename within the folder, and
updates all the links in the file to that found file. I wrote the code
that updates the links but I am struggling creating code that lets the
user choose the folder and filename. Searching around I found the
following code. It works wonderfully allowing the user to select a
folder. But how do I make it display the filenames within a folder and
let the user select one? Thanks for any help!
http://www.cpearson.com/excel/BrowseFolder.htm



mudraker[_374_]

Browse for file name code? (Excel 2002 VBA)
 

try

Dim sFile As String
sFile$ = Application.GetOpenFilename

you will still to add code to open the file

for save as try

sFile$ = Application.GetSaveAsFilename


--
mudraker
------------------------------------------------------------------------
mudraker's Profile: http://www.excelforum.com/member.php...fo&userid=2473
View this thread: http://www.excelforum.com/showthread...hreadid=536692


Doug Glancy

Browse for file name code? (Excel 2002 VBA)
 
One more option, available I think only in 2002 and later. It lets you set
an initial file:

Sub test()
Dim file_dialog As FileDialog

Set file_dialog = Application.FileDialog(msoFileDialogOpen)
With file_dialog
.AllowMultiSelect = False
.Title = "Pick a File to Link to if You Dare"
.ButtonName = "Link"
.InitialFileName = "C:\Documents and Settings\Doug\My Documents"
.Show
If .SelectedItems.Count = 1 Then
MsgBox .SelectedItems(1)
End If
End With
End Sub


--
Doug


wrote in message
ups.com...
Hello. I need to create a macro that displays a browser window, lets
the user choose a folder and then a filename within the folder, and
updates all the links in the file to that found file. I wrote the code
that updates the links but I am struggling creating code that lets the
user choose the folder and filename. Searching around I found the
following code. It works wonderfully allowing the user to select a
folder. But how do I make it display the filenames within a folder and
let the user select one? Thanks for any help!
http://www.cpearson.com/excel/BrowseFolder.htm




[email protected]

Browse for file name code? (Excel 2002 VBA)
 
Thanks for the ideas, but I searched a little more and found
Application.FileDialog to use instead of all that code. It's exactly
what I need.


Tom Ogilvy

Browse for file name code? (Excel 2002 VBA)
 
As long as you recognize that application.filedialog only works in xl2002 and
later.



--
Regards,
Tom Ogilvy


" wrote:

Thanks for the ideas, but I searched a little more and found
Application.FileDialog to use instead of all that code. It's exactly
what I need.




All times are GMT +1. The time now is 09:52 AM.

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