PDA

View Full Version : Solved: Help with Word.mvps Organising your Global Template article



Dave T
08-11-2010, 08:51 PM
Hello All,

I have been trying to work through the last part of an article from the Word.mvps site called "Organizing your macros" http://www.word.mvps.org/FAQs/MacrosVBA/OrganizeMacros.htm.


Just when I think I have done everything right and run the ShowGlobalTemplates UserForm I get the following error:
Compile error:
Member already exists in an object module from which this object module derives


If anyone can explain where I have gone wrong or what I have missed it would be greatly appreciated.

I did the following:

Created the UserForm and named it frmGlobal and used the caption name of "Load Global Template"
Created the Frame and labelled the caption as "Select Templates to Load"
Created the 3 OptionButtons and respectively named them optWordMcr, optMacros and optSupport
Created the OK OptionButton and named it cmdOK_Click and caption of OK
Created the Cancel OptionButton and named it cmdCancel_Click and caption of Cancel
Created a standard Module and copied the code and pasted it in the module
Copied and pasted the UserForm code in the UserForm
To run the macro I went Tools > Macro > Macros and selected Run on the ShowGlobalTemplates and the error message comes up.What have I done wrong or what have I missed ???

I have been using to following code to load / unload a single add-in, however I was just curious about the UserForm method shown as it can load more than one add-in.


Sub ActivateMyMacros()
AddIns("C:\Program Files\Microsoft Office\OFFICE11\STARTUP\MyMacros.dot"). _
Installed = Not AddIns("C:\Program Files\Microsoft Office\OFFICE11\STARTUP\MyMacros.dot").Installed
End Sub

Just out of curiosity what methods (and code examples please) do other people use to manage loading and unloading their add-ins ???

Regards,
Dave T
Word 2003

gmaxey
08-12-2010, 12:47 PM
Dave,

Does any Public Sub procedure (or Private procedure in the same project) have the same name as an object in your form?

Dave T
08-15-2010, 08:25 PM
Hello Greg,

Are you saying the problem is that as I have used cmdCancel_Click in the following code as well as having used it with the 'Cancel' buttons (name) on the UserForm.

Private Sub cmdCancel_Click()
Unload Me
End Sub
If this is the case how do I use the (name) property of the CommandButton and reference to it in the Sub code ???

PS I should have mentioned the toggle code inspiration came from Graham Mayor's site http://www.gmayor.com/lose_that_adobe_acrobat_toolbar.htm

Regards,
Dave T

gmaxey
08-15-2010, 08:38 PM
No that isn't what I am saying. I have only seen this error a few times and they can be tricky to resolve. It was always associated with having like named procedures. Can you send me your document? You can contact me from the Contact Me link on my website.

fumei
08-15-2010, 11:35 PM
Indeed, it is a duplicate naming error.

Dave T
08-20-2010, 12:23 AM
Hello All,

Both Greg and Gerry are correct,

I really appreciated Greg's offer to send him my document. When I got it back I had a close look at what Greg did and what I had been trying to do.

Thanks to both of you.

Regards,
Dave T