Solved

Using a central macro base for all users

Posted on 2013-11-25
6
129 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 48

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 48

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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 48

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now