Input box file name

kulmjord

Board Regular
Joined
Jul 9, 2015
Messages
53
Hey guys,

I am trying to automatically save a file when I exit a worksheet. I am also trying to use an input box to add text to the end of the file name. However every time I run the code it comes up with this error: "The specific dimension is not valid for the current chart type". The code is bellow and any help is appreciate.


Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Weekday(Date) = 6 Then
ChDir "G:\CHPP\METALLURGY\Reports\2017\CHPP Summary\Weekly"
    ActiveWorkbook.SaveAs Filename:= _
        "G:\CHPP\METALLURGY\Reports\2017\CHPP Summary\Weekly\01 January17" & InputBox("Date", "Input the date", Date) & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False _
        
End If
End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try this....but change the date format in the InputBox without Fwd slashes

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Weekday(Date) = 6 Then
fn = InputBox("Date", "Input the date", Date)
ChDir "G:\CHPP\METALLURGY\Reports\2017\CHPP Summary\Weekly"
    ActiveWorkbook.SaveAs Filename:= _
        "G:\CHPP\METALLURGY\Reports\2017\CHPP Summary\Weekly\01 January17" & fn & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End If
End Sub
 
Upvote 0
Try this....but change the date format in the InputBox without Fwd slashes

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Weekday(Date) = 6 Then
fn = InputBox("Date", "Input the date", Date)
ChDir "G:\CHPP\METALLURGY\Reports\2017\CHPP Summary\Weekly"
    ActiveWorkbook.SaveAs Filename:= _
        "G:\CHPP\METALLURGY\Reports\2017\CHPP Summary\Weekly\01 January17" & fn & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End If
End Sub

Awesome worked perfectly thanks.
 
Upvote 0
Please keep your questions to the Board, Nobody else gets the benefit of responses if you send Private mails

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Weekday(Date) = 6 Then
fn = InputBox("Date", "Input the date", Date)
If fn = vbNullString Then
Cancel = True
Exit Sub
End If
ChDir "G:\CHPP\METALLURGY\Reports\2017\CHPP Summary\Weekly"
    ActiveWorkbook.SaveAs Filename:= _
        "G:\CHPP\METALLURGY\Reports\2017\CHPP Summary\Weekly\01 January17" & fn & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End If
End Sub
 
Upvote 0
Please keep your questions to the Board, Nobody else gets the benefit of responses if you send Private mails

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Weekday(Date) = 6 Then
fn = InputBox("Date", "Input the date", Date)
If fn = vbNullString Then
Cancel = True
Exit Sub
End If
ChDir "G:\CHPP\METALLURGY\Reports\2017\CHPP Summary\Weekly"
    ActiveWorkbook.SaveAs Filename:= _
        "G:\CHPP\METALLURGY\Reports\2017\CHPP Summary\Weekly\01 January17" & fn & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End If
End Sub
Thanks for the help.
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,974
Members
448,537
Latest member
Et_Cetera

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