Solved

Referencing Excel macros

Posted on 2000-03-17
4
181 Views
Last Modified: 2010-05-02
I've got an Excel spreadsheet with various macros in VBA and a custom toolbar to access them.

The problem comes when different machines access the sheet since the toolbar buttons refer to the wrong location for the macros.

Is there a way to use an absolute reference for the buttons so that they point to the correct instance of the workbook??
0
Comment
Question by:Menthos1
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
Chrynoble earned 50 total points
ID: 2631802
I have been frustrated by this myself. I did not find a solution to fix this, but I might have a work around.

In the workbook_Open sub you could add code that would change the action a toolbar button performed.

Private Sub Workbook_Open()
 Set myBar = Application.CommandBars("NPC")
 Set myControl = myBar.Controls("Start")
 With myControl
   .OnAction = "X:\Folders\Filename.xls!NameofMacro"
 End With
 myBar.Visible = True
End Sub

You might also be able to set the "X:\Folders\File.xls!MacroName" in the assign area of the customize tool. I have not had the greatest success with this.
0
 

Author Comment

by:Menthos1
ID: 2643746
Ok this sounds just what I need...

Have you had any success with tagging the macros onto a different sheet and then referencing them from there - I can forsee a problem with running the macros from an instance of the sheet.
0
 

Author Comment

by:Menthos1
ID: 2643805
Sorry, that last comment made no sense at all...

What I meant to say was won't there be a problem with Excel trying to open another instance of the same sheet to access the macros.
0
 
LVL 1

Expert Comment

by:Chrynoble
ID: 2650210
Excel will look to open worksheets first. If Excel doesn't find the sheet there it will implicitly call the open command to open the workbook in question.

At least this is how it is suppose to work.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

914 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now