Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using a central macro base for all users

Posted on 2013-11-25
6
Medium Priority
?
149 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 53

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 53

Accepted Solution

by:
Rgonzo1971 earned 2000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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 53

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

971 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