Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

workbook openclose related code

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Workbook Open/Close Related Code

Workbook Open/Close Related Code

ResolvedVersion 2007

Mark has attended:
Excel VBA Intro Intermediate course
Excel Advanced - For Power Users course
Excel PowerPivot course
Excel Dashboards for Business Intelligence course

Workbook Open/Close Related Code

I have a spreadsheet where I have the code which hides the formula bar, the Excel ribbon and turns the calculations to manual when the file is opened.

Is there any equivalent code which will turn these back 'on' when the file is closed?

RE: Workbook Open/Close Related Code

Hi Mark

Thanks for getting in touch. If you have the code for turning them on, turning these events off again are often the reverse property. e.g.

Show the formula bar:

Application.DisplayFormulaBar = True

Turn on automatic calculation:

Application.Calculation = xlAutomatic

Turn on the ribbon:

Application.ExecuteExcel4Macro "Show.ToolBar(""Ribbon"",True)"

I hope this helps. Let us know if you have any problems.

Kind regards

Gary Fenn
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Workbook Open/Close Related Code

Hi Gary,

I've got the code to turn these all back on, it's the relating it to the workbook closing is where I'm coming unstuck. The code for the private_sub to turn these all on is below;

Private Sub Workbook_Open()

Application.Calculation = xlManual

Application.DisplayFormulaBar = False

Application.DisplayFullScreen = True

End Sub

I was hoping that there would be a Workbook_Close() entry?

RE: Workbook Open/Close Related Code

Hi Mark

Thanks for your reply. The event is slightly oddly named:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

You can find this by going to the ThisWorkbook object, choose the drop-down for Workbook and on the right browse the events.

Kind regards

Gary Fenn
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Workbook Open/Close Related Code

Thanks!

 

Training courses

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Hide columns in an Excel 2010 Worksheet

If you don’t want part of the Excel worksheet to be visible or when you don’t want certain data to appear in print outs, then a simple solution is to temporarily hide a column or multiple columns.

Hiding a single column:

1)Right click on the column header of the column you want to hide (this is the grey bar along the top edge of the worksheet)
2)Choose Hide from the menu
3)This column will now be hidden from view

Hide more than one column:

1)In the column header drag select to highlight the columns you want hidden
2)Right click and choose Hide from the menu

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.12 secs.