Is it possible to package the installation of a macro

C

Carlos Chalhoub

Hi listmates,

I have a couple of macros that I would like to install on my group's
computers. The installation is not as straightforward as creating a module
and dumping the code in it. I need to set some references and customize
toolbars and shortcuts. I had written detailed instructions on how to
proceed, but most of the users inb my group still had problems finishing the
installation without calling on me for help. I cannot count on the
instructions for a larger deployment. I know that I will be overwhelmed.

Is it possible to put all the different steps in some sort of a container (a
batch file?) that a user can just click on and launch an automatic
installation?
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Carlos Chalhoub > écrivait :
In this message, < Carlos Chalhoub > wrote:

|| Hi listmates,
||
|| I have a couple of macros that I would like to install on my group's
|| computers. The installation is not as straightforward as creating a
module
|| and dumping the code in it. I need to set some references and customize
|| toolbars and shortcuts. I had written detailed instructions on how to
|| proceed, but most of the users inb my group still had problems finishing
the
|| installation without calling on me for help. I cannot count on the
|| instructions for a larger deployment. I know that I will be overwhelmed.
||
|| Is it possible to put all the different steps in some sort of a container
(a
|| batch file?) that a user can just click on and launch an automatic
|| installation?

What are those steps?
Very often you can use VBA to install things with no input from the user,
other than clicking on a button to get it going.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
C

Carlos Chalhoub

Hi Jean-Guy,

The steps are:
1. Add a module in Normal.dot and dump the code in it.
2. Set references to Microsoft Internet Controls and Microsoft HTML Object
Library.
3. Add a "link" to the macro in Shortcut Menus through Tools -> Customize.
4. Add a button on the standard toolbar.

Thanks
Carlos
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Carlos Chalhoub > écrivait :
In this message, < Carlos Chalhoub > wrote:

|| Hi Jean-Guy,
||
|| The steps are:
|| 1. Add a module in Normal.dot and dump the code in it.
|| 2. Set references to Microsoft Internet Controls and Microsoft HTML
Object
|| Library.
|| 3. Add a "link" to the macro in Shortcut Menus through Tools ->
Customize.
|| 4. Add a button on the standard toolbar.
||

First of all, are you sure you want to dump your stuff in the user's
Normal.dot? This file can be flaky and recreated almost at will.
Why not a global template?
If you use a Global template, you can do all of the above manually once in
your template, then just tell your user where to put the file (Their
Start-up folder).

Otherwise, you need to have a document that will activate code like this:

'_______________________________________
'1
'To add a module
'Export it from your source
Application.VBE.ActiveVBProject.VBComponents(1).Export ("test.bas")
'Then import where you want it
Application.VBE.ActiveVBProject.VBComponents.Import ("test.bas")
'look these up in the help file
'For example:
Const MyMod_Path As String = "C:\WINDOWS\Temp\MyMod.bas"

Application.VBE.ActiveVBProject.VBComponents("Test_Module").Export
(MyMod_Path)
Application.VBE.VBProjects("Normal").VBComponents.Import (MyMod_Path)

'_______________________________________

'_______________________________________
'2
'Using Registry info
Application.VBE.ActiveVBProject.References.AddFromFile
'Using file name and path
Application.VBE.ActiveVBProject.References.AddFromGuid
'_______________________________________

'_______________________________________
'3 and 4
'First make sure that your toolbar changes are stored where they ought to
be:
CustomizationContext = NormalTemplate
'Other possibilities are:
'CustomizationContext = AttachedTemplate
'CustomizationContext = ActiveDocument

'Then create the controls
Dim MyBar As CommandBar
Dim newButton As CommandBarButton
Set MyBar = CommandBars("Standard")
Set newButton = MyBar.Controls _
.Add(msoControlButton)
With newButton
.Caption = "Click here"
.OnAction = "MyProject.MyModule.MySub"
.TooltipText = "To activate the macro, click on this button"
End With
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
C

Carlos Chalhoub

Salut Jean-Guy,

I've got to admit that I did not even consider a Global Templates. I'll
investigate it. Thanks for the code, I'll go through it and adapt it to our
needs.

Merci beaucoup.
Carlos
 
H

Howard Kaikow

Two of my own commandments are:

Never put code in the Normal template unless absolutely necessary.

Never modify toolbars/menus in the Normal template unless absolutely.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top