LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Excel macro to add an hyperlink that shows only the filename (no p

Hi all :)

I'm trying to make this work, just clicking a button, open a file dialog,
and adding an hyperlink in the selected cell showing only the name of the
file, without the path.
I have this code already done. The problem is: when calling the functions
LastIndexOf and Substring I receive a compiler error: Invalid qualifier for
any variable I use. How can I solve this? Thank you in advance!! ^^

Dim vrtSelectedItem As Variant
Dim Nom1 As String
Dim Nom2 As String
Dim y As String

Public Sub Linking_Click()

Dim fd As FileDialog

Set fd = Application.FileDialog(msoFileDialogFilePicker)

With fd

If .Show = -1 Then

For Each vrtSelectedItem In .SelectedItems

Nom2 = vrtSelectedItem
Nom1 = Ruta(Nom2)

If vrtSelectedItem < "" Then
ActiveSheet.Hyperlinks.Add Anchor:=Selection,
Address:=vrtSelectedItem
y = ActiveCell.Address
ActiveSheet.Range(y) = Nom1
End If
Next vrtSelectedItem

Else
End If
End With

Set fd = Nothing
End Sub

Function Ruta(item As String) As String

Dim lastLocation As Integer

lastLocation = item.LastIndexOf("\")
If lastLocation = 0 Then
' remove the identified section, if it is a valid region
Ruta = item.Substring(0, lastLocation)
End If

End Function
 
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
Excel 2007 Taskbar Tab shows Icon + "Microsoft Excel - filename" glastron99 Excel Discussion (Misc queries) 6 September 1st 17 07:07 PM
Hyperlink macro - with filename xavi garriga Excel Programming 1 January 12th 09 03:18 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
Macro to change filename of the Hyperlink maperalia Excel Programming 0 November 1st 05 11:59 PM


All times are GMT +1. The time now is 01:16 PM.

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

About Us

"It's about Microsoft Excel"