ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   File Browse Function (Open dialog box for choosing file) (https://www.excelbanter.com/excel-programming/338361-file-browse-function-open-dialog-box-choosing-file.html)

b-123

File Browse Function (Open dialog box for choosing file)
 

Hi all-

I tried searching through the forum but couldn't find answer:

I want to add a command button to a form where if a user clicks it a
file browse window comes up (like for opening a file) and if a user
navigates through and selects a file I assign the path to this file as
a hyperlink to an entry in a spreadsheet - so that a future user can
open this file just by clicking on the link.

I learned how to assign hyperlink by doing a macro record, but do not
know how to incorporate file browse function. any help would be much
appreciated.


--
b-123
------------------------------------------------------------------------
b-123's Profile: http://www.excelforum.com/member.php...o&userid=26649
View this thread: http://www.excelforum.com/showthread...hreadid=399227


Jake Marx[_3_]

File Browse Function (Open dialog box for choosing file)
 
Hi b-123,

Something like this should work for you:

Sub Demo()
Dim vFilePath As Variant

vFilePath = Application.GetOpenFilename(FileFilter:= _
"Microsoft Excel Files (*.xls), *.xls", Title:= _
"Please select a file to hyperlink.")

If vFilePath < False Then
With Sheet1
.Hyperlinks.Add Anchor:=.Range("A1"), _
Address:=vFilePath
End With
End If
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


b-123 wrote:
Hi all-

I tried searching through the forum but couldn't find answer:

I want to add a command button to a form where if a user clicks it a
file browse window comes up (like for opening a file) and if a user
navigates through and selects a file I assign the path to this file as
a hyperlink to an entry in a spreadsheet - so that a future user can
open this file just by clicking on the link.

I learned how to assign hyperlink by doing a macro record, but do not
know how to incorporate file browse function. any help would be much
appreciated.



All times are GMT +1. The time now is 01:40 PM.

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