View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Help with Excel Add-in

Create a new workbook.

Add your macros to a general module........no buttons or assignments yet.

Save As an Add-in to your Office Library.

Close and re-open Excel

Open a workbook and browse ToolsAdd-ins for your new add-in.

Load it by checkmark.

Now add a button or menu item and "assign macro"

Type in just the macroname because you will not see any macros in the "Assign
Macro" dialog box and you won't need the add-in name prepended.

But keep Dave's advice about creating "on the fly" menus and toolbars. in mind
for the future.


Gord


On Tue, 15 Jan 2008 17:03:01 -0800, FJ wrote:

Hi, Gord, I've tried it both ways. I've tried starting with a regular xls
workbook, creating a macro, and assigning it to a button, and I've also tried
to just create the macro and assign it to the button and then save it as an
xla without saving it as an xls first.

I tried changing the button assignment to just be the name of the macro
without any of the "Book1.xls!macroname" type of thing, but it just always
seems to revert back to looking for an xls no matter what I do. I have been
assigning the macro to the button by going to Tools, Options, Customize,
Assign Macro, but do I have to assign or change anything anywhere else for
this to work?

Sorry if this is all basic stuff. I'm just a beginner.




"Gord Dibben" wrote:

Before the workbook was saved as an add-in did you have buttons with macros
assigned to them?

These assignments would have included the workbook name as you
show....Book1.xls!macroname

When you saved as an add-in then changed the nameas you stated you did, the
assignments would not have changed and are still looking for Book1.xls

You will have to change button assignments to just the macro name.

Macros in add-ins don't need the workbook reference.

Right-click on the button or menu item when in ToolsCustomize and hit "assign
macro"

Delete the Book1,xls reference so you are left with macroname only.


Gord Dibben MS Excel MVP

On Tue, 15 Jan 2008 11:30:02 -0800, FJ wrote:

Hi, Peter. The problem is, I can't get it to work from a custom button,
either. I click on the button and it gives me a message like, "The macro
'Book1.xls!Name of Macro' cannot be found".

As I said to Bob, I'm just very confused about all this and I'm probably
doing something very wrong on a very basic level. I also don't really
understand why it keeps telling me that a .xls file can't be found. I
thought the point of an add-in was that once you had it loaded, the macros in
it would be available to other workbooks. Or does it always have to be
associated with a regular .xls workbook on each computer where you want to
use the macros in that add-in?

Sorry if this is a really basic question. All this is very new to me.




"Peter T" wrote:

"FJ" wrote in message

Hi, Bob, thanks for your response. Actually, the thing is that when I
open a
new workbook and go into the VBE, I can see the macro code, but I can't
see
the macros listed when I go to dialog box under Tools, Macro, Macros on
the
worksheet itself. Shouldn't they be listed in that dialog box if the
add-in
is loaded correctly?

Macros in addins are not listed in the macros dialog, they are typically
activated from a custom menu button that you have added.

To get you started you can add a button manually with Customize menus, try
the smiley face listed under 'macros'. Place it where you want and assign
your macro. Later though you will probably want to add and remove your
custom menu buttons programmatically.

Regards,
Peter T