Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Opening a document captured by Application.GetOpenFilename with hyperlink

Hi Nils,

Try something like:

'=============
Private Sub CommandButton1_Click()
Dim FName As Variant
Dim sStr As String
Dim iPos As Long

FName = Application.GetOpenFilename( _
FileFilter:="Excel Files (*.xls), *.xls")

If FName = False Then
Exit Sub
Else
iPos = InStrRev(FName, Application.PathSeparator)
sStr = Mid(FName, iPos + 1)
ActiveSheet.Hyperlinks.Add _
Anchor:=ActiveCell, _
Address:=FName, _
TextToDisplay:=sStr
End If
End Sub
'<<=============


---
Regards,
Norman


wrote in message
oups.com...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Opening a document captured by Application.GetOpenFilename with hyperlink

On 16 Maj, 17:43, "Norman Jones"
wrote:
Hi Nils,

Try something like:

'=============
Private Sub CommandButton1_Click()
Dim FName As Variant
Dim sStr As String
Dim iPos As Long

FName = Application.GetOpenFilename( _
FileFilter:="Excel Files (*.xls), *.xls")

If FName = False Then
Exit Sub
Else
iPos = InStrRev(FName, Application.PathSeparator)
sStr = Mid(FName, iPos + 1)
ActiveSheet.Hyperlinks.Add _
Anchor:=ActiveCell, _
Address:=FName, _
TextToDisplay:=sStr
End If
End Sub
'<<=============

---
Regards,
Norman

wrote in message

oups.com...



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- Dölj citerad text -


- Visa citerad text -


Norman,

It works perfectly! Thank you!!

//Nils

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.GetOpenFileName Chris Excel Programming 7 August 19th 06 12:37 AM
Application.GetOpenFilename vs Application.Dialogs(xlDialogsOpen) Paul Martin Excel Programming 5 August 5th 05 04:44 PM
Application.GetOpenFilename Nigel Excel Programming 0 March 23rd 05 03:24 PM
Application.GetOpenFilename Philipp Oberleitner[_2_] Excel Programming 2 July 9th 04 07:29 PM
Application.GetOpenFileName ptrowe Excel Programming 2 September 11th 03 12:54 PM


All times are GMT +1. The time now is 06:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"