Wednesday, November 30, 2011

Macro to close the current worbook without saving and reopen the same workbook

Sub ClosewithoutsaveAndReopen()

'Defines Variables
Dim nameOfCurrentWorkbook As Variant
Dim nameOfCurrentWorkbookPath As Variant

'Finds the name of the current workbook
    nameOfCurrentWorkbook = ActiveWorkbook.Name
'finds the current path of hte workbook
    nameOfCurrentWorkbookPath = ActiveWorkbook.Path
    ActiveWorkbook.Close False
'Reopens the same worbook you just closed
    Workbooks.Open (nameOfCurrentWorkbookPath & "\" & nameOfCurrentWorkbook)
End Sub

No comments:

Post a Comment