View Single Post
  #6   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

How do you know it's not saving?

Maybe you could put a
msgbox "Saved as " & activeworkbook.fullname
at the end of whatever the name of that procedure is that does the save.



Danny wrote:

Thanks, but i'm still havig the same problem, and get the Compile error -
Expected variable or proceder, not module.

And when i change the module name, it will not give me this error, but does
not save at all.

"JLatham" wrote:

I think I may have had wrong post chosen when I replied before, but no matter
- I realized right after posting that we need to reset that flag after it
gets used, so the _BeforeSave code needs a slight modification:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As _
Boolean, Cancel As Boolean)
If justSayYes Then
justSayYes = False ' reset it
Exit Sub ' continue with save normally
End If
Call myBook_Save
Cancel = True
End Sub


"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