Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2007 Taskbar Tab shows Icon + "Microsoft Excel - filename" | Excel Discussion (Misc queries) | |||
Hyperlink macro - with filename | Excel Programming | |||
My excel macro recorder no longer shows up when recording macro | Excel Discussion (Misc queries) | |||
My excel macro recorder no longer shows up when recording macro | Excel Discussion (Misc queries) | |||
Macro to change filename of the Hyperlink | Excel Programming |