close workbook and reopen it

SQUIDD

Well-known Member
Joined
Jan 2, 2009
Messages
2,104
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi all

Is there a way of making something that closes the workbook down and re-opens it again without saving the previous work.
I have some code that runs, saves various things and creates reports etc.
But when it has finished and i want to paste new info into it, i have to close it and then re-open it, would be great to make it happen by itself ready for the next lot of data.
Thanks

dave
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
And here is direct answer on your question - yes it is possible to reload previously saved workbook without saving changes.
Try:
Rich (BB code):

Sub ReloadMe()
  Application.DisplayAlerts = False
  ThisWorkbook.Saved = True
  ThisWorkbook.ChangeFileAccess Mode:=xlReadOnly
  Workbooks.Open ThisWorkbook.FullName
  Application.DisplayAlerts = True
End Sub
 
Last edited:
Upvote 0
Sorry Dave
I wasn't suggesting you were fibbing....I was simply amazed that it actually did work....
Excel / VBA never stops astounding me.

Cheers
 
Upvote 0
Hi Micheal

Never thought that for a moment.:LOL:
Thanks for all your help.
I seem to have moved onto a bigger problem that is way over my head.
No takers yet:(

Thanks, and I was also surprised that there way a way to do this?

dave
 
Upvote 0
Rich (BB code):

Sub ReloadMe()
  Application.DisplayAlerts = False
  ThisWorkbook.Saved = True
  ThisWorkbook.ChangeFileAccess Mode:=xlReadOnly
  Workbooks.Open ThisWorkbook.FullName
  Application.DisplayAlerts = True
End Sub
This line is an extra: ThisWorkbook.ChangeFileAccess Mode:=xlReadOnly
The simplified code:
Rich (BB code):

Sub ReloadMe()
  Application.DisplayAlerts = False
  ThisWorkbook.Saved = True
  Workbooks.Open ThisWorkbook.FullName
  Application.DisplayAlerts = True
End Sub
 
Last edited:
Upvote 0
Do you need DisplayAlerts?
Code:
Sub ReloadMe()
    ThisWorkbook.Saved = True
    Workbooks.Open ThisWorkbook.FullName
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,603
Members
449,089
Latest member
Motoracer88

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