View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default paste file name of an OFFice program into a cell

code will open a Pop-Up window and allow you to select a file then put in a
hyperlink to the file you select.

Sub AddLink()

CurrentDir = ThisWorkbook.Path
CurrentDir = "c:\temp"
FName = Application _
.GetOpenFilename( _
"Text Files (*.txt), *.txt," & _
"Power Point Files (*.ppt), *.ppt," & _
"Visio Files (*.vsd), *.vsd," & _
"All Files (*.*), *.*")

Set fs = CreateObject("Scripting.FileSystemObject")
FBaseName = fs.GetBaseName(FName)


ActiveCell.Hyperlinks.Add _
Anchor:=Selection, _
Address:=FName, _
TextToDisplay:=FBaseName

End Sub


"Henry" wrote:

I would like an Excel user to be able to go to a cell, and then paste the
file name ,(preferably without the full path, but that is not an absolute
need,) into the cell. The file will be in the same folder, and will be a
Word, Visio or Powerpoint file.
The purpose is an Excel 2003 sales CRM program, where sales types can add
the name of the contract or "sales pitch" to this cell on a shared network.
Then management will be able to click on the cell and review the sales
document
I am not a sophisticated user, with no working knowledge of VB or macros.
but I can follow directions