ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   BeforeSave Event Question (https://www.excelbanter.com/excel-programming/337004-beforesave-event-question.html)

Andibevan[_4_]

BeforeSave Event Question
 
Hi All,

I am trying to create a beforeSave event so that when the user presses save,
an inputbox comes up and the user specifies part of the filename and then
the code automatically adds additional information to the filename. I have
two problems:-

1) My code causes excel to crash
2) The inputbox comes up twice for some reason

Any ideas:-

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As

Boolean)

Dim FilePath As String

Dim varInput As String



FilePath = "S:\SmartMarket\SMV Project Administration\Sign-Offs\Construct

Phase\"




On Error GoTo addError

varInput = InputBox("......\Sign-Offs\Construct Phase\SMV - Sign-Off

for XXXXX.xls", _

"Sign-off Sheet Description")



ActiveWorkbook.SaveAs Filename:=FilePath & varInput & ".xls"




addError:



MsgBox "No value submitted - File Not Saved"





End Sub

Ta

Andi




All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com