Status & Formula Bar Disabling Prevention Among Other Opened Workb

E

Edd

HI,

I want to disable the Status and Formula bars for a workbook when it is
opened but only for this one specific workbook and not for any other opened
workbooks. I use the below two lines of code.

Application.DisplayStatusBar = False
Application.DisplayFormulaBar = False

How can I prevent these actions from occuring with other opened workbooks?

Thanks,
 
J

Jim Thomlinson

You need to go to thisworkbook and place code in the necessary worbook events
to capture when you are looking at the current workbook. Something like
this...

Private Sub Workbook_Activate()
Application.DisplayStatusBar = False
Application.DisplayFormulaBar = False
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayStatusBar = True
Application.DisplayFormulaBar = True
End Sub

Private Sub Workbook_Deactivate()
Application.DisplayStatusBar = True
Application.DisplayFormulaBar = True
End Sub

Private Sub Workbook_Open()
Application.DisplayStatusBar = False
Application.DisplayFormulaBar = False
End Sub
 
E

Edd

Jim,

How can I prevent the activate event from firing when I go a different
worksheet within the same workbook? I only want it to fire for one of the
worksheets and not the rest. I tried something like the below to fire when
only sheet1 is in focus, but it does not work. Can you please help? Thanks!

Private Sub WorkbookActivate()
If Sheet1.Visible Then
Application.DisplayStatusBar = False
Application.DisplayFormulaBar = False
End If
End Sub

(Note: I also tried the windowactivate, sheetactivate, and they seem to
operate identically, and they do not work).
 
D

Dave Peterson

There is a worksheet event (not a workbook level event) that can be used. It
goes in under the worksheet that you want (rightclick on that worksheet's tab
and select view code.)

It'll fire when you go from any other sheet in this same workbook to this sheet.

Option Explicit
Private Sub Worksheet_Activate()
msgbox "hi from: " & me.name
End Sub

It won't fire when you change from one workbook to this workbook.
 
E

Edd

Dave,

"It goes in under the worksheet," now why did I not think of that??? Well,
I'm glad I have you guys to think for me. That worked as I intended. Thanks
so much!!

Ed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top