[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Referencing Excel macros

Posted on 2000-03-17
4
Medium Priority
?
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
Chrynoble earned 150 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

650 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