hungledink
Board Regular
- Joined
- Feb 20, 2012
- Messages
- 88
- Office Version
- 365
Hi,
I've made an excel workbook that basically just adds a desktop shortcut to another excel file when a user clicks a custom button. This works as intended if I specify the full drive path and file name in the macro.
My problem is, that we use a shared drive at work, and people have assigned this shared drive to different letters, some have it as drive Z, others drive K and so on.
If I send it out via email therefore, the macro wont know which drive letter is assigned as the active shared drive.
Is there any way around this?
Here is the code I found online to create the desktop shortcut, I modified it slightly.
Hopefully that makes sense.
Thanks in advance.
I've made an excel workbook that basically just adds a desktop shortcut to another excel file when a user clicks a custom button. This works as intended if I specify the full drive path and file name in the macro.
My problem is, that we use a shared drive at work, and people have assigned this shared drive to different letters, some have it as drive Z, others drive K and so on.
If I send it out via email therefore, the macro wont know which drive letter is assigned as the active shared drive.
Is there any way around this?
Here is the code I found online to create the desktop shortcut, I modified it slightly.
VBA Code:
Sub CreateShortCut()
Dim oWSH As Object
Dim oShortcut As Object
Dim sPathDeskTop As String
Set oWSH = CreateObject("WScript.Shell")
sPathDeskTop = oWSH.SpecialFolders("Desktop")
Set oShortcut = oWSH.CreateShortCut(sPathDeskTop & "\" & _
ActiveWorkbook.Name & ".lnk")
With oShortcut
.TargetPath = ActiveWorkbook.FullName
.Save
End With
Set oWSH = Nothing
End Sub
Hopefully that makes sense.
Thanks in advance.