Thread: Save a file as
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Save a file as


Forgot to mention that you need to mention the path..like

ActiveWorkbook.SaveAs Filename:= "c:\" & "Galashiels Resources WC " &
Range("N2")

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


"Jacob Skaria" wrote:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Do you want to save as 'Galashiels Resources WC " & Range("N2") & _
"'", vbYesNo + vbInformation, "Galashiels Operational Resources © MN
") = vbYes Then
ActiveWorkbook.SaveAs Filename:= "Galashiels Resources WC " & Range("N2")
ActiveWorkbook.Close
Else
ActiveWorkbook.Close savechanges:=false
End If
End Sub


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


"terilad" wrote:

Can anyone help me with a piece of code to put in place of "Do something if
answer is yes"

Here is the code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Do you want to save as 'Galashiels Resources WC " & Range("N2") & _
"'", vbYesNo + vbInformation, "Galashiels Operational Resources © MN
") = vbYes Then
'Do something if answer is yes
End If
End Sub

I am looking for a command to put in the code to replace: 'Do something if
answer is yes, I want this to save a file as the new name e.g Resources WC
and the range N2 on the desktop, if no is selected I want the workbook to
close and make no changes, can you help with this code.

Regards


Mark