PDA

View Full Version : How to close the all excel workbooks once i open a one excel workbook



shailendranr
02-18-2016, 09:48 PM
Hello Everyone

I have prepared one tool in my office , that tool is very much useful and i got good appreciation as well , now i have one issue with that, i have stuck with that problem, i.e.,if i open that excel , i can work with other excel workbooks , so am planning write workbook open event procedure code in such a way that , once i open a tool other excel workbooks has save and close , if excel workbooks which has not saved has save in default path of desktop ..can u guys help with this

shailendranr
02-18-2016, 09:52 PM
This is a code i thought , can u guys help me to enhance it , how to save and close a workbooks in default path.

Sub closewbook()


Rem to close all workbooks except this w.book(tool)


Dim singlewbook As Workbook


For Each singlewbook In Workbooks


If singlewbook.Name <> ThisWorkbook.Name Then
singlewbook.Close True
End If


Next singlewbook


End Sub