View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default how to get a macro to work

Try renaming that module (not the procedure) to something else:

Mod_Workbook_save
???

Danny wrote:

Hi There,

I have received some info through this posting, but it is not working how i
want to.
Hoppefully someone can help me further?

I have a Macro in a Module (Workbook_save)

Sub Workbook_Save()
Dim rng As Range

Set rng = ActiveSheet.Range("M2")

ActiveWorkbook.SaveAs _
Filename:=rng.Value & ".xls", _
FileFormat:=xlWorkbookNormal

End Sub

And a macro to start up the above in This workbook:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call Workbook_Save
Cancel = True
End Sub

But for some reason it is not saving the file as supose to do, i get the
error:
Compile Error - Expected variable or Proceder, not module

How can tell me what this is and how to fix?

Thanks


--

Dave Peterson