?
Solved

Custom word toolbar

Posted on 2011-10-11
7
Medium Priority
?
236 Views
Last Modified: 2012-05-12
Hello,

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)
0
Comment
Question by:sbsbats
  • 3
  • 2
  • 2
7 Comments
 
LVL 76

Expert Comment

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

Expert Comment

by:xtermie
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
0
 

Author Comment

by:sbsbats
ID: 36958512
HI Graham,

Have attached the 3 files - custom toolbar and the 2 macros
Ctoolbar.dot
Inserthbs.dot
Insertsbs.dot
0
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

by:
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.
0
 
LVL 76

Assisted Solution

by:GrahamSkan
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.
0
 

Author Comment

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

Author Closing Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

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