Solved

Using a central macro base for all users

Posted on 2013-11-25
6
135 Views
Last Modified: 2013-12-13
I generate workbooks for the timesheets of each staff member from a master workbook. This generated workbook contains some macros. Whenever I add/update the macros they are available for the staff in the following month only. I was wondering if there could be a system wherein each of the generated workbook contains a caller macro which calls a central macro in a file residing on the server so that any changes done during the month are immediately affected to all workbooks.

PS: All macros are event-fired. None of them are user-invoked. The events at the moment are worksheet_change and worksheet_selectionchange but may have to be expanded.
0
Comment
Question by:Saqib Husain, Syed
  • 3
  • 3
6 Comments
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39674429
Hi,

you could create an XL add-in with all procedures

refer all the events to the add-in subs, for the ones you don't yet use,  keep an empty sub

to call the add-in

 
Sub MyTest() 
    Application.Run ("myaddin.xla!mySelectionChange") 
End Sub 

Open in new window

Regards
0
 
LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 39679839
Is there a way for a macro to install/update the addin? I do not want to go myself to install the addin on all computers. Some people bring their own laptop and I might not be available to do the installation.
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39680002
Hi,

you could send your user a file with this code to install an add in

as workbook_open code

Sub CheckAndInstall()
   
    myAddInName = "Addin Name"
    File = "S:\AddinLocation\myAddin.xla"
    
    On Error Resume Next
    Result = AddIns(myAddInName).Installed
    On Error GoTo 0
                                            
    If IsEmpty(Result) Then
        Set myAddin = Application.AddIns.Add(Filename:=File)
        myAddin.Installed = True
        Application.AddIns(myAddInName).Installed = True
    ElseIf Application.AddIns(myAddInName).Installed = False Then
        Application.AddIns(myAddInName).Installed = True
    End If
End Sub

Open in new window


and then in the add-in this code (I've changed my mind on how to change the code)

Private Sub Workbook_Open()
    'rename the module
    ThisWorkbook.VBProject.VBComponents("Module1").Name = "ModuleTemp"
    'remove the module
    ThisWorkbook.VBProject.VBComponents.Remove ThisWorkbook.VBProject.VBComponents("ModuleTemp")
    'Import the module
    ThisWorkbook.VBProject.VBComponents.Import ("f:\GlobalCode\Module1.bas")
    ThisWorkbook.VBProject.VBComponents(ThisWorkbook.VBProject.VBComponents.Count).Name = "Module1"
        

End Function

Open in new window

Regards
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 43

Author Comment

by:Saqib Husain, Syed
ID: 39680058
Hi, Thanks for the effort. The looks are now good. But it is going to take e some time to test it. Please bear with me while I get the time to test it.

Saqib
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39680081
Hi,

if do not want to have your add-in centrally saved you could use

MsgBox Application.StartupPath

to get the startup folder of each user

Regards
0
 
LVL 43

Author Closing Comment

by:Saqib Husain, Syed
ID: 39716013
Sorry, I could not test it but it is time to close this now,

Thanks for everything.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question