Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Using Autoshapes as macro buttons

Hi, I have created a model in Excel 2007 using autoshapes as macro buttons.
However, sometimes when I copy, rename or move the file, the buttons lose
their macro assignment. It doesn't seem to matter when I'm using it in 2003
or 2007. Is this a bug in Excel, or should I just not use autoshapes as
macro buttons?


  #2   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Using Autoshapes as macro buttons

Hi Plum -

It's OK to use autoshapes or any shape to present the user with a visual que
to fire a macro. However, assignment of a macro to any shape (even if it's a
toolbar button or a button on a worksheet) needs to be handled with care or
the symptom you describe can and will occur.

It's not considered a 'bug', but Excel can 'lose track' of a macro that's
assigned to a button or shape. For example, if a worksheet containing a
shape (with and assigned macro) is copied to another workbook and then the
original workbook is deleted or its name is changed, your symptom will arise.
There are other causes for this problem, too, most of which occur
unexpectedly.

To avoid this, try putting the macro code in the worksheet module instead of
a standard module. VBA always looks in this module first when a macro path
is not specified, so you never have to worry about VBA not finding it (if you
can click the shape, the code always resides with the shape's underlying
worksheet - the shape and the code are always connected and move together so
moving, renaming, and deleting files has no negative impact).

A suggestion, too, is to use the "New" button when assigning the macro and
pasting your code into the macro name that is provided by vba (Sub
AutoShape1_Click, for example).

One final word of caution: shapes can be unpredictably renamed if you do a
lot of shape editing, adding shapes, grouping, ungrouping, deleting, etc. If
you do a lot of shape editing, just be aware that you might (might) have to
reassign the macro (using "New") if a shape_click suddenly stops working.
Rest assured, however, that once you're done editing and have your final
layout, the macro code and the shape will work properly.

---
Jay



"Plum" wrote:

Hi, I have created a model in Excel 2007 using autoshapes as macro buttons.
However, sometimes when I copy, rename or move the file, the buttons lose
their macro assignment. It doesn't seem to matter when I'm using it in 2003
or 2007. Is this a bug in Excel, or should I just not use autoshapes as
macro buttons?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using Autoshapes as macro buttons



"Jay" wrote:

Hi Plum -

It's OK to use autoshapes or any shape to present the user with a visual que
to fire a macro. However, assignment of a macro to any shape (even if it's a
toolbar button or a button on a worksheet) needs to be handled with care or
the symptom you describe can and will occur.

It's not considered a 'bug', but Excel can 'lose track' of a macro that's
assigned to a button or shape. For example, if a worksheet containing a
shape (with and assigned macro) is copied to another workbook and then the
original workbook is deleted or its name is changed, your symptom will arise.
There are other causes for this problem, too, most of which occur
unexpectedly.

To avoid this, try putting the macro code in the worksheet module instead of
a standard module. VBA always looks in this module first when a macro path
is not specified, so you never have to worry about VBA not finding it (if you
can click the shape, the code always resides with the shape's underlying
worksheet - the shape and the code are always connected and move together so
moving, renaming, and deleting files has no negative impact).

A suggestion, too, is to use the "New" button when assigning the macro and
pasting your code into the macro name that is provided by vba (Sub
AutoShape1_Click, for example).

One final word of caution: shapes can be unpredictably renamed if you do a
lot of shape editing, adding shapes, grouping, ungrouping, deleting, etc. If
you do a lot of shape editing, just be aware that you might (might) have to
reassign the macro (using "New") if a shape_click suddenly stops working.
Rest assured, however, that once you're done editing and have your final
layout, the macro code and the shape will work properly.

---
Jay



"Plum" wrote:

Hi, I have created a model in Excel 2007 using autoshapes as macro buttons.
However, sometimes when I copy, rename or move the file, the buttons lose
their macro assignment. It doesn't seem to matter when I'm using it in 2003
or 2007. Is this a bug in Excel, or should I just not use autoshapes as
macro buttons?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using Autoshapes as macro buttons

Hi folks, If I could open this up to include assigning macro's to custom
buttons in custom toolboxes, which is virtually the same process as assigning
a macro to an autoshape, I find the problem is, when I assign a macro and the
Assign macro window pops up, there is an option to select "This Workbook".
When you select a macro it appears without a path but as soon as you close
the window and open it again, the macro is appened with a path, and the path
includes the name of the excel file. If I rename the excel file then the
path is no longer valid and "marcro not found" results. Is it possible to
provide only the macro name within the workbook, no path data, so it only
looks inside the workbook regardless of it's current file name?
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using Autoshapes as macro buttons

Sorry I must have made a bad mouse click and accidentally posted this, now I
cannot figure out how to delete it (new to this forum). Please ignore this
posting.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro buttons opening saved macro Wasabijim Excel Discussion (Misc queries) 0 April 29th 09 08:39 PM
Macro Buttons Lois Excel Worksheet Functions 4 April 1st 09 03:33 PM
Replacing macro buttons with a new set of buttons jonco Excel Programming 3 July 3rd 06 01:36 AM
Visual Basic Autoshapes Macro Dav Excel Discussion (Misc queries) 2 December 14th 05 05:33 PM
assigning macros to buttons or autoshapes John of the new year Excel Worksheet Functions 1 June 10th 05 01:31 AM


All times are GMT +1. The time now is 05:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"