Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Autoshape Macro

You might try Edit, Links and change the link to point to the workbook
itself.

--
Jim
"Rob Kings" wrote in message
...
| Apologies if this is an FAQ. I couldn't find an answer when I looked in
| Google.
|
| Its difficult to explain, but here goes:
|
| 1. I have a workbook and on the some of the sheets in this workbook are
| Autoshapes with macros assigned.
|
| 2. The VBA for the macros is in the sheet itself (rather than a module)
|
| 3. In code (from another Workbook) I copy the sheet into a new workbook
(Be
| that Book1 or whatever, it hasn't been saved yet)
|
| 4. The autoshapes don't work, because the Macro references are in the form
| 'Originalworkbook'!Macroname
|
| However, 'Macroname' does exist. so how do I either:
|
| a) Use a form of words in the macro assignment so that it looks in the
| current sheet
|
| b) Alter the assignments at runtime.
|
| Any ideas?
|
| Cheers
|
| Rob
|
|


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Autoshape Macro

Jim

I don't think that's going to help me. At the time I'm trying to run this
code I haven't yet saved the workbook.

The situation is this:

1. I have an XLS with some AutoShapes (basically doing sheet navigation)
These shapes run some VBA (that is in the sheet, rather than a separate
module)

2. At runtime I copy the sheet from the XLS into my active workbook. This
includes the code routines, but the autoshape has an explicit reference to
the old XLS

If I click the shape it tries to open the original file.

Since the code does exist it seems odd that I can't just call it using the
<SheetName.<Subroutine style, but even if you enter the macro in this
form, it still saves using the full '<Workbook'!<SheetName.<Subroutine
form.

Rob

"Jim Rech" wrote in message
...
You might try Edit, Links and change the link to point to the workbook
itself.

--
Jim
"Rob Kings" wrote in message
...
| Apologies if this is an FAQ. I couldn't find an answer when I looked in
| Google.
|
| Its difficult to explain, but here goes:
|
| 1. I have a workbook and on the some of the sheets in this workbook are
| Autoshapes with macros assigned.
|
| 2. The VBA for the macros is in the sheet itself (rather than a module)
|
| 3. In code (from another Workbook) I copy the sheet into a new workbook
(Be
| that Book1 or whatever, it hasn't been saved yet)
|
| 4. The autoshapes don't work, because the Macro references are in the
form
| 'Originalworkbook'!Macroname
|
| However, 'Macroname' does exist. so how do I either:
|
| a) Use a form of words in the macro assignment so that it looks in the
| current sheet
|
| b) Alter the assignments at runtime.
|
| Any ideas?
|
| Cheers
|
| Rob
|
|




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Autoshape Macro

Can you fix the links on the new (copied) with something like this?:

Sub FixLinks()
Dim Sh As Shape
Dim Mac As String
On Error GoTo NoBang
For Each Sh In ActiveSheet.Shapes
Mac = Sh.OnAction
Sh.OnAction = ActiveWorkbook.Name & "!" & Mid(Mac, InStr(1, Mac,
"!") + 1)
NextShape:
Next
Exit Sub
NoBang:
Resume NextShape
End Sub

--
Jim
"Rob Kings" wrote in message
...
| Jim
|
| I don't think that's going to help me. At the time I'm trying to run this
| code I haven't yet saved the workbook.
|
| The situation is this:
|
| 1. I have an XLS with some AutoShapes (basically doing sheet navigation)
| These shapes run some VBA (that is in the sheet, rather than a separate
| module)
|
| 2. At runtime I copy the sheet from the XLS into my active workbook. This
| includes the code routines, but the autoshape has an explicit reference to
| the old XLS
|
| If I click the shape it tries to open the original file.
|
| Since the code does exist it seems odd that I can't just call it using the
| <SheetName.<Subroutine style, but even if you enter the macro in this
| form, it still saves using the full '<Workbook'!<SheetName.<Subroutine
| form.
|
| Rob
|
| "Jim Rech" wrote in message
| ...
| You might try Edit, Links and change the link to point to the workbook
| itself.
|
| --
| Jim
| "Rob Kings" wrote in message
| ...
| | Apologies if this is an FAQ. I couldn't find an answer when I looked
in
| | Google.
| |
| | Its difficult to explain, but here goes:
| |
| | 1. I have a workbook and on the some of the sheets in this workbook
are
| | Autoshapes with macros assigned.
| |
| | 2. The VBA for the macros is in the sheet itself (rather than a
module)
| |
| | 3. In code (from another Workbook) I copy the sheet into a new
workbook
| (Be
| | that Book1 or whatever, it hasn't been saved yet)
| |
| | 4. The autoshapes don't work, because the Macro references are in the
| form
| | 'Originalworkbook'!Macroname
| |
| | However, 'Macroname' does exist. so how do I either:
| |
| | a) Use a form of words in the macro assignment so that it looks in the
| | current sheet
| |
| | b) Alter the assignments at runtime.
| |
| | Any ideas?
| |
| | Cheers
| |
| | Rob
| |
| |
|
|
|
|


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Autoshape Macro

Jim

Cool that seems to work OK. I'd guess I'd liked to have found a "non-code"
solution (since it seems a reasonable thing to want to do) but this will be
fine, since I'm running other code in any case.

Cheers

Rob

"Jim Rech" wrote in message
...
Can you fix the links on the new (copied) with something like this?:

Sub FixLinks()
Dim Sh As Shape
Dim Mac As String
On Error GoTo NoBang
For Each Sh In ActiveSheet.Shapes
Mac = Sh.OnAction
Sh.OnAction = ActiveWorkbook.Name & "!" & Mid(Mac, InStr(1, Mac,
"!") + 1)
NextShape:
Next
Exit Sub
NoBang:
Resume NextShape
End Sub

--
Jim
"Rob Kings" wrote in message
...
| Jim
|
| I don't think that's going to help me. At the time I'm trying to run
this
| code I haven't yet saved the workbook.
|
| The situation is this:
|
| 1. I have an XLS with some AutoShapes (basically doing sheet navigation)
| These shapes run some VBA (that is in the sheet, rather than a separate
| module)
|
| 2. At runtime I copy the sheet from the XLS into my active workbook.
This
| includes the code routines, but the autoshape has an explicit reference
to
| the old XLS
|
| If I click the shape it tries to open the original file.
|
| Since the code does exist it seems odd that I can't just call it using
the
| <SheetName.<Subroutine style, but even if you enter the macro in this
| form, it still saves using the full
'<Workbook'!<SheetName.<Subroutine
| form.
|
| Rob
|
| "Jim Rech" wrote in message
| ...
| You might try Edit, Links and change the link to point to the workbook
| itself.
|
| --
| Jim
| "Rob Kings" wrote in message
| ...
| | Apologies if this is an FAQ. I couldn't find an answer when I looked
in
| | Google.
| |
| | Its difficult to explain, but here goes:
| |
| | 1. I have a workbook and on the some of the sheets in this workbook
are
| | Autoshapes with macros assigned.
| |
| | 2. The VBA for the macros is in the sheet itself (rather than a
module)
| |
| | 3. In code (from another Workbook) I copy the sheet into a new
workbook
| (Be
| | that Book1 or whatever, it hasn't been saved yet)
| |
| | 4. The autoshapes don't work, because the Macro references are in
the
| form
| | 'Originalworkbook'!Macroname
| |
| | However, 'Macroname' does exist. so how do I either:
| |
| | a) Use a form of words in the macro assignment so that it looks in
the
| | current sheet
| |
| | b) Alter the assignments at runtime.
| |
| | Any ideas?
| |
| | Cheers
| |
| | Rob
| |
| |
|
|
|
|




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 to Fit AutoShape over Range? Wart Excel Discussion (Misc queries) 7 July 22nd 08 07:39 PM
autoshape macro jackrobyn1 Excel Discussion (Misc queries) 1 October 13th 07 11:33 PM
macro in vba to display autoshape jrd269[_6_] Excel Programming 0 June 7th 05 08:45 PM
Remove macro from autoshape dee Excel Programming 4 January 22nd 05 12:21 PM
AutoShape name assigned to macro Larry Excel Programming 4 October 19th 04 04:15 PM


All times are GMT +1. The time now is 11:25 PM.

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

About Us

"It's about Microsoft Excel"