View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] nilshalvarsson@hotmail.com is offline
external usenet poster
 
Posts: 7
Default Opening a document captured by Application.GetOpenFilename with hyperlink

Hi,

Im am creating a user interface in Excel to keep track of a workflow
and I have two questions:

1. One of the steps in the workflow is to "upload" a document to
verify that the document has been created. I use a button (code below,
which I found on this forum) to paste the file name in a designated
cell, and this works fine. I would like the users to be able to click
the hyperlink to open the document. How is this done?

2. Is it possible to show just the file name, without the path? I do
not get the dir() command to work.

I've searched the forum, but I cannot find any answers to my
questions. Really thankful for any help!

//Nils

Private Sub CommandButton3_Click()

Dim FileName As Variant
Dim Title As String
Dim i As Integer
Dim Msg As String

' Set the dialog box caption
Title = "Select a File to Import"


' Get the file name
FileName = Application.GetOpenFilename _
(FileFilter:=Filt, _
FilterIndex:=FilterIndex, _
Title:=Title, _
MultiSelect:=True)


' Exit if dialog box canceled
If Not IsArray(FileName) Then
MsgBox "No file was selected."
Exit Sub
End If

' Display full path and name of the files
For i = LBound(FileName) To UBound(FileName)
Msg = Msg & FileName(i) & vbCrLf
Next i
MsgBox "You selected:" & vbCrLf & Msg
link1 = Msg

' Paste the file name as hyperlink in cell C13
Range("C13").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=Msg

End Sub