Open macro saved on shared network drive

emoandy05

Board Regular
Joined
Sep 4, 2013
Messages
60
Hello all!

I have a workbook that users will be downloading/exporting from an external source. Once downloaded, I have two hotkeys that run two macros. I would like the location of the macro to be saved on the shared drive, so when a user hits the hotkeys, excel will still know to look for the macro on the shared drive. But in the case of the personal file saved under xlstart, I would like that to remain there so if the user created their own macro for something else, they will still have their personal macros on their local drive.

Is there a way to specify the location/address of a particular macro? This way, if there is ever an update made to it, I can just update the macro on the shared drive and will not have to sent out updates versions to every user.

Thank you in advance for your help and please let me know if there is anything I can clarify.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
I could do that, but that would still require each user to take that initial step of creating the shortcut. Great idea though. I just want this to be foolproof so the user just has to run the macro using the hotkeys.
 
Upvote 0
Hi

It turns out that creating a shortcut is not all that complicated, take a look at this page:
Creating File Shortcuts (VBA: Office XP) | Windows Secrets Lounge

With the info from that page I made put the two following macros in a workbook.

Code:
Sub CreateAShortcut _(FileName As String, _
Target As String, _
Optional WorkingDirectory As String, _
Optional WindowStyle As Integer = vbNormalFocus, _
Optional Description As String)


With CreateObject("WScript.Shell").CreateShortcut(FileName)
    .TargetPath = Target
    .WindowStyle = WindowStyle
    .Description = Description
    .WorkingDirectory = WorkingDirectory
    .Save
End With
End Sub

Code:
Sub StartShortCut()    
Dim path As String
path = Application.StartupPath
    
CreateAShortcut path & "\Shortcut.lnk", "D:\Testmappe\Filename.xlsx", , vbMaximizedFocus
End Sub

I suppose you could put the last one in the startup-event of your workbook so that when your users open the file the first time the shortcut is created.
Obviously you need to change "D:\Testmappe\Filename.xlsx" to whatever your path is.

I have uploaded a sample workbook here:
https://dl.dropboxusercontent.com/u/12632/Open macro saved on shared network drive.xlsm

I cannot take credit for any of this code, but hopefully it is of some use.
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,178
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top