Hi all,
recently I created an user form in PERSONAL.XLSB with 4 command buttons. Half of them change name of current file and save it in specific folder, the rest opens specific file. Since I added this form I have a problem with my excel. Every time I close any workbook, it takes some time to do it (like 3-5 seconds). Then excel restarts itself with empty workbook and shows previously saved workbook as a recovery file. Is it possible that some of this macros is corrupting excel?
recently I created an user form in PERSONAL.XLSB with 4 command buttons. Half of them change name of current file and save it in specific folder, the rest opens specific file. Since I added this form I have a problem with my excel. Every time I close any workbook, it takes some time to do it (like 3-5 seconds). Then excel restarts itself with empty workbook and shows previously saved workbook as a recovery file. Is it possible that some of this macros is corrupting excel?
VBA Code:
Private Sub SaveTicket_Click()
' MACRO TO ADD TICKET NUMBER TO AN ACTIVE FILE
Dim NewName As String
NewName = InputBox("Insert Ticket Number", "Change file's name")
Dim CurrentName As String
CurrentName = ActiveWorkbook.Name
Dim WS As Workbook
Set WS = ActiveWorkbook
WS.SaveAs "C:\Local\Tickets\" & NewName & " " & CurrentName
Unload Me
End Sub
VBA Code:
Private Sub SavePrices_Click()
Dim FName As String
FName = "C:\Local\Prices\Prices " & _
Format(Date, "YYYYMMDD") & ".xlsx"
ActiveWorkbook.SaveAs Filename:=FName, _
FileFormat:=xlOpenXMLWorkbook
Unload Me
End Sub
VBA Code:
Private Sub OpenSalesPrices_Click()
Dim MyPath As String
Dim MyFile As String
Dim LatestFile As String
Dim LatestDate As Date
Dim LMD As Date
MyPath = "C:\Local\Prices\"
If Right(MyPath, 1) <> "\" Then MyPath = MyPath & "\"
MyFile = Dir(MyPath & "*.xlsx", vbNormal)
If Len(MyFile) = 0 Then
MsgBox "No files were found.", vbExclamation
Exit Sub
End If
Do While Len(MyFile) > 0
LMD = FileDateTime(MyPath & MyFile)
If LMD > LatestDate Then
LatestFile = MyFile
LatestDate = LMD
End If
MyFile = Dir
Loop
Workbooks.Open MyPath & LatestFile
Unload Me
End Sub
VBA Code:
Private Sub OpenSetToOb_Click()
Workbooks.Open "C:\Local\Personal\OB.xlsm"
Unload Me
End Sub