Solved

Referencing Excel macros

Posted on 2000-03-17
4
176 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

708 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

17 Experts available now in Live!

Get 1:1 Help Now