Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Macro execution changes filename reference for all macros

Hi Fred,

I don't know what might have caused the change. However, the problem is to
get it working now. I have assumed that these buttons are Forms buttons; not
ActiveX Command Buttons. Therefore, save the OnAction for each of the buttons
prior to moving the worksheet and then reset the OnAction in the new
worksheet. The following code should do it.

I have tested this in xl2007 and it appears to work satisfactorily. However,
I will monitor the thread and feel free to get back to me if any problems.

Sub PreserveOnAction()
Dim shp As Shape
Dim arrAction()
Dim i As Long
Dim j As Long

With ActiveSheet

'Redim a 2 dimensional 1 based array
'with sufficient elements for all shapes
ReDim arrAction(1 To _
.Shapes.Count, 1 To 2)

For Each shp In .Shapes
If shp.OnAction < "" Then
i = i + 1
arrAction(i, 1) = shp.Name
arrAction(i, 2) = shp.OnAction
End If
Next shp

.Name = "Publication"
.Move
End With

'Publication will now be the active sheet
With Sheets("Publication")
'Some shapes might not have an OnAction
'and some elements at the end of the array
'might be blank.
'Therefore use i as the upper limit when
'retrieving the data from the array.
For j = 1 To i
.Shapes(arrAction(j, 1)) _
.OnAction = arrAction(j, 2)
Next j
End With

End Sub


--
Regards,

OssieMac


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 reference changes with filename Louis Sweere Excel Discussion (Misc queries) 1 November 7th 07 11:47 AM
Using filename hyperlinks in Macros [email protected] Excel Programming 7 December 20th 06 11:10 PM
Macros - Force execution using workbook_open Guy Normandeau Excel Discussion (Misc queries) 3 July 6th 06 08:29 PM
Reference in a filename.. Frode Hjoennevaag Excel Worksheet Functions 3 April 14th 05 02:47 PM
macros execution problem Lolly[_2_] Excel Programming 1 April 7th 05 02:42 PM


All times are GMT +1. The time now is 06:53 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"