Forum Discussion
Excel rewrites my hyperlinks to sharepoint
don242can unfortunately, I have not seen a resolution to this issue. Sorry to hear it has set you back.
- Rod_HorningJul 11, 2022Copper Contributor
Maybe this will work
Make vCommand a Variant
Instead of Dim vCommand as String, use Dim vCommand as Variant
- Rod_HorningJul 11, 2022Copper Contributor
- don242canJul 14, 2022Copper Contributor
Thanks for digging into a solution. I ended up dealing with it in a bit of a messy way that worked for my need. I just built the links as text in a hidden cell, stringing together the local location with the rest of the path and then created the hyperlink off that text.
Not the prettiest solution, but at least I didn't lose all the work I did to create this.
- Rod_HorningJul 11, 2022Copper ContributorMaybe... Dim vCommand as String change to Dim vCommand as Variant
- Rod_HorningJul 11, 2022Copper Contributor
Grrr. Just ran into another EXCEL got you. If the hyperlink address is to long (and I don't know how long is long) then selection.hyperlinks(1).address does not return the full address. Instead it returns ../../ and the right hand portion of the full address.
- Rod_HorningJul 11, 2022Copper Contributor
This code expects the selected cell to be a hyperlink.
Private Sub CommandButton1_Click()
Dim vCommand As String
Dim PID As VariantvCommand = "mspaint.exe " & Chr(34) & Selection.Hyperlinks(1).Address & Chr(34)
PID = Shell(vCommand, vbMaximizedFocus)End Sub
- Rod_HorningJul 11, 2022Copper Contributor
I found a possible solution. I created a VBA SUB that will start mspaint.exe and open the .JPG
I added a command button to invoke the VBA SUB
The code expects a cell with the full path name to the picture to be selected before clicking the command button
Here is the code:
Private Sub Display_Picture_Click()
Dim vCommand as String
Dim PID As Variant' The next two lines of code remove the " on the right and left end of the path name
'vCommand = Right(Selection.Value, Len(Selection.Value) - 1)
'vCommand = Left(vCommand, Len(vCommand) - 1)' The next line adds the paint app name, mspaint.exe
vCommand = "mspaint.exe " & Selection.Value' The next line start mspaint and passes the file path
PID = Shell(vCommand, vbNormalFocus)
End Sub- Rod_HorningJul 11, 2022Copper ContributorOops. You will probably need to remove the ' mark on the two lines that remove the "
Sorry