paste file name of an OFFice program into a cell

  • Thread starter Thread starter Henry
  • Start date Start date
H

Henry

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top