ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   assigned macro taking the name of file creating it. Please help. (https://www.excelbanter.com/excel-programming/273152-re-assigned-macro-taking-name-file-creating-please-help.html)

Dave Peterson[_3_]

assigned macro taking the name of file creating it. Please help.
 
Without setting up the workbooks to copy the macro for car_allowance into each
project (I just copies manually), this change seemed to get the right workbook.

Selection.OnAction = ActiveSheet.Parent.Name & "!Car_Allowance"



a wrote:

Hi,

I'm trying to add some buttons and a module to a group of files. This
is the code I use to add the button and assign the macro and add the module.

This all works (these are just fragments of the code) but the macro that
is assigned is preceded by the file name of the file that I am using to
insert the module and add the button.

Is there any way around this?

As always, any help would be much appreciated.

Anita

Set SourceModule = _
Workbooks("AddingModule.xls").VBProject.VBComponen ts("Module3").CodeModule

Set DestModule = _
Workbooks(fileWextention).VBProject.VBComponents(" CarAllowance").CodeModule
With SourceModule
DestModule.AddFromString ( _
.Lines(.ProcStartLine("Home_Car_Allowance", vbext_pk_Proc), _
.ProcCountLines("Home_Car_Allowance", vbext_pk_Proc)))

End With
ActiveSheet.Unprotect ("nope")
ActiveSheet.Buttons.Add(1125.75, 179.25, 129.75, 14.25).Select

Selection.Characters.Text = "Car Allowance"
With Selection.Characters(Start:=1, Length:=13).Font
.Name = "MS Sans Serif"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.OnAction = "Car_Allowance"


--

Dave Peterson


Anita Gray

assigned macro taking the name of file creating it. Please help.
 


A

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 07:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com