Custom word toolbar

Posted on 2011-10-11
Medium Priority
Last Modified: 2012-05-12

I have the strangest error and am starting to get frustrated - I have 2 macros, each contains the same code and simply inserts a specific image into a doc (only diff is the image and name). Both macros work sweet individually.
I now need to add these 2 macros to an existing custom toolbar I have - I open this template(Ctoolbar) and then add the 2 macros to the toolbar (Tools - Customize). When I then run the macros from the button, both insert the same image no matter what. I can even create 2 seperate custom toolbars, add a macro to each one and run it and still both deliver the same image (it seems to toggle which image to load sometimes if I delete and try to re-produce)
Question by:sbsbats
  • 3
  • 2
  • 2
LVL 76

Expert Comment

ID: 36954066
I can't guess what might cause that. Is it possible to post the template that contains the code and the toolbars?
LVL 18

Expert Comment

ID: 36954346
We definetely need to see the code and the button in a sample excel file.
Are you sure you have attached a different macro to each button?
Are the images in the same folder?
Please post a sample file

Author Comment

ID: 36958512
HI Graham,

Have attached the 3 files - custom toolbar and the 2 macros
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

LVL 18

Accepted Solution

xtermie earned 1000 total points
ID: 36959117
The problem is that you are using the same macro name, that's causing the confusion.
Name one macro Sub InsertPictureShape()
 and the second one Sub InsertPictureShape2() for example and then attach accordingly to the proper buttons.
LVL 76

Assisted Solution

GrahamSkan earned 1000 total points
ID: 36959475
I agree with xtermie.

You have posted three templates. One contains the toolbar, while the other two each have an identically named macro (InsertPictureShape) which is the name of the macro that both buttons call. It isn't clear how the templates currently relate to each other, but I suggest that you combine the three into a single template with one of the macros renamed.

Author Comment

ID: 36959768
Thanks guys - considered combining into one but was not sure how to assign diff modules within a project to seperate custom buttons

Author Closing Comment

ID: 36959971
Thanks guys - thanks for all your help this week Graham

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Ever wonder what it's like to get hit by ransomware? "Tom" gives you all the dirty details first-hand – and conveys the hard lessons his company learned in the aftermath.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

830 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