ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how do i do something for every spreadsheet i open? (https://www.excelbanter.com/excel-programming/329052-how-do-i-do-something-every-spreadsheet-i-open.html)

Drew Krum

how do i do something for every spreadsheet i open?
 
So many spreadsheets come to me with the Reviewing toolbar visible. I've
created code to make it invisible. How can I have that code run every time I
open a spreadsheet (attachment, hard drive, ULR)? Every new spreadsheet? When
I open Excel?

Thank you,
Drew

sebastienm

how do i do something for every spreadsheet i open?
 
Hi,

You can create a small addin or add the following code to an already
existing one that opens with excel.

Add a Class module called ClsBarCanceller and paste the following code:

'---------------------------------------------------------------
Private WithEvents App As Application

'When a book opens, hide reviewing toolbar
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
on error resume next
App.CommandBars("Reviewing").Visible = False
on error goto 0
End Sub

Private Sub Class_Initialize()
Set App = Application
End Sub

Private Sub Class_Terminate()
Set App = Nothing
End Sub
'-------------------------------------------------

and in a regular code module, add the public object variable:

'--------------------------------------------------
Public BarCanceller As New ClsBarCanceller
'--------------------------------------------------

Now, if you added the above code to an already existing addin, it will work
by itself.
If it is a new one, set its IsAddin property to True (select ThisWorkbook in
the project explorer and set the property in the Properties Window). Finally
save the book and copy it in the xlstart folder:
C:\Documents and Settings\<USERNAME\Application
Data\Microsoft\Excel\XLSTART
with <USERNAME being your Windows login name.
This will make it open each time excel opens and will make the code active.

I hope this helps,

Regards,
Sébastien

"Drew Krum" wrote:

So many spreadsheets come to me with the Reviewing toolbar visible. I've
created code to make it invisible. How can I have that code run every time I
open a spreadsheet (attachment, hard drive, ULR)? Every new spreadsheet? When
I open Excel?

Thank you,
Drew



All times are GMT +1. The time now is 12:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com