opinionated86
New Member
- Joined
- Feb 2, 2016
- Messages
- 12
I've created the following macro (from bits and bobs on forums) to save a shortcut of the current file in the startup folder of my computer, if i just manually create a shortcut it works so i know i can edit this folders contents but when i run this macro it produces and error about not being able to save shortcut. Any help would be great.
Thanks
Code:
Sub new_flexi_user()startup = "C:\Users\" & UserName & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\" & Replace(ThisWorkbook.Name, ".xlsm", ".lnk")
Dim sShortcutLocation As String
sShortcutLocation = startup
With CreateObject("WScript.Shell").CreateShortcut(sShortcutLocation)
.TargetPath = ThisWorkbook.FullName
.Description = "Shortcut to the file"
.Save
End With
End Sub
Thanks