Auto Save File

MarkReddell

Board Regular
Joined
Sep 1, 2011
Messages
210
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
I need to Auto. save my Excel File to my Customer's name in B4; however if there is no entry in b4; I need a message box to prompt me toenter a name before save file!!! Im using this code:

(Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",True)"
MsgBox ("This File is Being Saved in the Customer's Name & to the MSN SkyDrive Web-site In The Business Folder! Goodbye For Now")
ActiveWorkbook.SaveAs Filename:="https://ptkmnm.docs.live.net/a7f2fe19067884e3/BUSINESS/" & Sheets("LOAN SCENARIOS").Range("B4").Value & ".xlsm"
End Sub)

THANX FOR ANY HELP!!!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Try this:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
 
    Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",True)"
    MsgBox ("This File is Being Saved in the Customer's Name & to the MSN SkyDrive Web-site In The Business Folder! Goodbye For Now")
 
    If Len(Range("B4")) = 0 Then
        Cancel = True
        MsgBox "You must enter a name in cell B4 and try again!"
    Else
        ActiveWorkbook.SaveAs Filename:="[URL]https://ptkmnm.docs.live.net/a7f2fe19067884e3/BUSINESS/[/URL]" & Sheets("LOAN SCENARIOS").Range("B4").Value & ".xlsm"
    End If
 
End Sub
 
Upvote 0
Thanx Joe4 "4" your help!!! It's a blessing 2 have help out there!!! God's Blessings 2 U & family in the CHRISTmas Season!!!
 
Upvote 0
Thank you for the kind words. Right back at you!;)
 
Upvote 0
Hey Joe4, Thanx for your reply!!! How would I insert a pause in this code after i goto "B4" and wait for an entry, then continue the Macro to save & close the file in the customer's name? (Private Sub Workbook_BeforeClose(Cancel As Boolean)

Application.ExecuteExcel4Macro "show.toolbar(""Ribbon"",True)"
MsgBox ("This File is Being Saved in the Customer's Name & to the MSN SkyDrive Web-site In The Business Folder! Goodbye For Now")

If Len(Range("B4")) = 0 Then
Cancel = True
MsgBox "You must enter a name in cell B4 and try again!"
Else
ActiveWorkbook.SaveAs Filename:="https://ptkmnm.docs.live.net/a7f2fe19067884e3/BUSINESS/" & Sheets("LOAN SCENARIOS").Range("B4").Value & ".xlsm"
End If

End Sub)
 
Upvote 0
If you wanted to do something like that, I would approach it a bit differently. I would have the Macro prompt the user for an entry (using an Input Box) and then you can populate B4 with the value of this Input Box and continue with your macro.
 
Upvote 0

Forum statistics

Threads
1,215,220
Messages
6,123,697
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top