ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   'Open File' Functionality (https://www.excelbanter.com/excel-programming/375153-open-file-functionality.html)

den1s

'Open File' Functionality
 
I am looking to add 'open file' functionality to a VBA program. I would
like to give the user the ability to browse a through directories to
find and select a file. The functionality would be similar to the
window that comes up when you go to File/Open.

Is there a simple way to add this functionality (perhaps a VBA command)
or is there freely available code that does this?

thanks

- db79


jonesy

'Open File' Functionality
 
Here is some VBA code that I have used to "browse" for a file, then
display the document's name into the selected cell.


Sub browse1()

Range("E6").Select
Var1 = Application.GetOpenFilename(FileFilter:="Word Files (*.doc),
*.doc", Title:="Full Document Name")
fileToOpen = Right(Var1, Len(Var1) - InStrRev(Var1,
Application.PathSeparator))
ActiveCell.Value = fileToOpen

End Sub



All times are GMT +1. The time now is 09:56 PM.

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