View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Syntax to Run Macro in ActiveWorkbook


Dim strWB As String
strWB = ActiveWorkbook.Name
ActiveSheet.Shapes("myShp").OnAction = _
strWB & "!TheNewMacroName"

OR

ActiveSheet.Shapes("myShp").OnAction = _
ActiveWorkbook.Name & "!TheNewMacroName"

If this post helps click Yes
---------------
Jacob Skaria


"Trevor Williams" wrote:

Hi All

I have a macro that copies a sheet containing another macro to the
ActiveWorkbook.

I need to update the OnAction command of a shape to run the macro attached
to the new sheet. I can get it working using absolute values, but need to
change the workbook part to ActiveWorkbook -- but can't suss out the syntax.

Here's the absolute line:
ActiveSheet.Shapes("myShp").OnAction = _
"'my file name.xls'!TheNewMacroName"

I need something like this:
ActiveSheet.Shapes("myShp").OnAction = _
ActiveWorkbook.name!TheNewMacroName

TIA
Trevor Williams