Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Macro not doing?

The following doesn,t work and I have no idea why - any suggestions?
I am assuming the code should run when the worksheet "Data Input" is
selected.

'Code in Sheet1 "Data Input"
Private Sub Worksheet_Activate()

Sheets("Data Input").Unprotect Password:="********"

ClearApplicationControls

Sheets("Data Input").Protect Password:="********"

End Sub

'Code in Module2
Sub ClearApplicationControls()

Application.ScreenUpdating = False

With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
.DisplayHeadings = False
.WindowState = xlMaximized
End With

Dim OneBar As CommandBar
On Error Resume Next
For Each OneBar In CommandBars
OneBar.Visible = False
Next
On Error GoTo 0

With Application
.DisplayFullScreen = False
.DisplayFormulaBar = False
End With

Application.ScreenUpdating = True

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Macro not doing?

Is it running at all? If not, you may have somehow set

Application.EnableEvents = FALSE

and not reset it back to TRUE.

In the Immediate window, thpe
Application.EnableEvents = TRUE

Go to another worksheet and then reactivate the DataInput sheet.

If this

Private Sub Worksheet_Activate()

Sheets("Data Input").Unprotect Password:="********"

ClearApplicationControls

Sheets("Data Input").Protect Password:="********"

End Sub


Is in the Data INput worksheet code, you don't need the Sheets("Data
Input"). part


"Sandy" wrote:

The following doesn,t work and I have no idea why - any suggestions?
I am assuming the code should run when the worksheet "Data Input" is
selected.

'Code in Sheet1 "Data Input"
Private Sub Worksheet_Activate()

Sheets("Data Input").Unprotect Password:="********"

ClearApplicationControls

Sheets("Data Input").Protect Password:="********"

End Sub

'Code in Module2
Sub ClearApplicationControls()

Application.ScreenUpdating = False

With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
.DisplayHeadings = False
.WindowState = xlMaximized
End With

Dim OneBar As CommandBar
On Error Resume Next
For Each OneBar In CommandBars
OneBar.Visible = False
Next
On Error GoTo 0

With Application
.DisplayFullScreen = False
.DisplayFormulaBar = False
End With

Application.ScreenUpdating = True

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro not doing?

You can't change visible to false it is read only, but you can disable. here
is the modified code. Had to make additional changes to prevent errors. I
also commented out on error so i could debug the problem

Dim OneBar As CommandBar
barcount = CommandBars.Count
' On Error Resume Next
For bars = 1 To barcount
CommandBars.Item(bars).Enabled = False
Next bars
' On Error GoTo 0


"Sandy" wrote:

The following doesn,t work and I have no idea why - any suggestions?
I am assuming the code should run when the worksheet "Data Input" is
selected.

'Code in Sheet1 "Data Input"
Private Sub Worksheet_Activate()

Sheets("Data Input").Unprotect Password:="********"

ClearApplicationControls

Sheets("Data Input").Protect Password:="********"

End Sub

'Code in Module2
Sub ClearApplicationControls()

Application.ScreenUpdating = False

With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
.DisplayHeadings = False
.WindowState = xlMaximized
End With

Dim OneBar As CommandBar
On Error Resume Next
For Each OneBar In CommandBars
OneBar.Visible = False
Next
On Error GoTo 0

With Application
.DisplayFullScreen = False
.DisplayFormulaBar = False
End With

Application.ScreenUpdating = True

End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Macro not doing?

Hi Barb
I can't explain this but it suddenly decided to do???
I'm unaware of having made any other change - Strange.
I'll take your point on board about not needing the Sheets("Data Input")
part though - thank you
Sandy

"Barb Reinhardt" wrote in message
...
Is it running at all? If not, you may have somehow set

Application.EnableEvents = FALSE

and not reset it back to TRUE.

In the Immediate window, thpe
Application.EnableEvents = TRUE

Go to another worksheet and then reactivate the DataInput sheet.

If this

Private Sub Worksheet_Activate()

Sheets("Data Input").Unprotect Password:="********"

ClearApplicationControls

Sheets("Data Input").Protect Password:="********"

End Sub


Is in the Data INput worksheet code, you don't need the Sheets("Data
Input"). part


"Sandy" wrote:

The following doesn,t work and I have no idea why - any suggestions?
I am assuming the code should run when the worksheet "Data Input" is
selected.

'Code in Sheet1 "Data Input"
Private Sub Worksheet_Activate()

Sheets("Data Input").Unprotect Password:="********"

ClearApplicationControls

Sheets("Data Input").Protect Password:="********"

End Sub

'Code in Module2
Sub ClearApplicationControls()

Application.ScreenUpdating = False

With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
.DisplayHeadings = False
.WindowState = xlMaximized
End With

Dim OneBar As CommandBar
On Error Resume Next
For Each OneBar In CommandBars
OneBar.Visible = False
Next
On Error GoTo 0

With Application
.DisplayFullScreen = False
.DisplayFormulaBar = False
End With

Application.ScreenUpdating = True

End Sub





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro not doing?

Sandy I don't think the OneBar.Visible = False is working. The On Error
statement is bypassing the statement and doing nothing.

"Sandy" wrote:

Hi Barb
I can't explain this but it suddenly decided to do???
I'm unaware of having made any other change - Strange.
I'll take your point on board about not needing the Sheets("Data Input")
part though - thank you
Sandy

"Barb Reinhardt" wrote in message
...
Is it running at all? If not, you may have somehow set

Application.EnableEvents = FALSE

and not reset it back to TRUE.

In the Immediate window, thpe
Application.EnableEvents = TRUE

Go to another worksheet and then reactivate the DataInput sheet.

If this

Private Sub Worksheet_Activate()

Sheets("Data Input").Unprotect Password:="********"

ClearApplicationControls

Sheets("Data Input").Protect Password:="********"

End Sub


Is in the Data INput worksheet code, you don't need the Sheets("Data
Input"). part


"Sandy" wrote:

The following doesn,t work and I have no idea why - any suggestions?
I am assuming the code should run when the worksheet "Data Input" is
selected.

'Code in Sheet1 "Data Input"
Private Sub Worksheet_Activate()

Sheets("Data Input").Unprotect Password:="********"

ClearApplicationControls

Sheets("Data Input").Protect Password:="********"

End Sub

'Code in Module2
Sub ClearApplicationControls()

Application.ScreenUpdating = False

With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
.DisplayHeadings = False
.WindowState = xlMaximized
End With

Dim OneBar As CommandBar
On Error Resume Next
For Each OneBar In CommandBars
OneBar.Visible = False
Next
On Error GoTo 0

With Application
.DisplayFullScreen = False
.DisplayFormulaBar = False
End With

Application.ScreenUpdating = True

End Sub








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Macro not doing?

Hi Joel
You are right it isn't. Your solution does though - thank you.
I now have another minor problem - how do I then enable all that was
disabled. Otherwise all of these Toolbars remain out of commission in other
workbooks. The final code I used is as follows:

Sub ClearApplicationControls()

Application.ScreenUpdating = False

With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
.DisplayHeadings = False
.WindowState = xlMaximized
End With

Dim OneBar As CommandBar
barcount = CommandBars.Count
On Error Resume Next
For bars = 1 To barcount
CommandBars.Item(bars).Enabled = False
Next bars
On Error GoTo 0

With Application
.DisplayFullScreen = False
.DisplayFormulaBar = False
.CommandBars("Worksheet Menu Bar").Enabled = True
End With

Application.ScreenUpdating = True

End Sub

If I just set the "CommandBars.Item(bars).Enabled = True" then it fails. I'm
guessing something would be required within a "before_close" event?
Sorry to be a pest.
Sandy

"Joel" wrote in message
...
Sandy I don't think the OneBar.Visible = False is working. The On Error
statement is bypassing the statement and doing nothing.

"Sandy" wrote:

Hi Barb
I can't explain this but it suddenly decided to do???
I'm unaware of having made any other change - Strange.
I'll take your point on board about not needing the Sheets("Data Input")
part though - thank you
Sandy

"Barb Reinhardt" wrote in
message
...
Is it running at all? If not, you may have somehow set

Application.EnableEvents = FALSE

and not reset it back to TRUE.

In the Immediate window, thpe
Application.EnableEvents = TRUE

Go to another worksheet and then reactivate the DataInput sheet.

If this

Private Sub Worksheet_Activate()

Sheets("Data Input").Unprotect Password:="********"

ClearApplicationControls

Sheets("Data Input").Protect Password:="********"

End Sub


Is in the Data INput worksheet code, you don't need the Sheets("Data
Input"). part


"Sandy" wrote:

The following doesn,t work and I have no idea why - any suggestions?
I am assuming the code should run when the worksheet "Data Input" is
selected.

'Code in Sheet1 "Data Input"
Private Sub Worksheet_Activate()

Sheets("Data Input").Unprotect Password:="********"

ClearApplicationControls

Sheets("Data Input").Protect Password:="********"

End Sub

'Code in Module2
Sub ClearApplicationControls()

Application.ScreenUpdating = False

With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
.DisplayHeadings = False
.WindowState = xlMaximized
End With

Dim OneBar As CommandBar
On Error Resume Next
For Each OneBar In CommandBars
OneBar.Visible = False
Next
On Error GoTo 0

With Application
.DisplayFullScreen = False
.DisplayFormulaBar = False
End With

Application.ScreenUpdating = True

End Sub








  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Macro not doing?

It only change the toolbars on one worksheet. to reverse change
from
CommandBars.Item(bars).Enabled = False

to
CommandBars.Item(bars).Enabled = True


"Sandy" wrote:

Hi Joel
You are right it isn't. Your solution does though - thank you.
I now have another minor problem - how do I then enable all that was
disabled. Otherwise all of these Toolbars remain out of commission in other
workbooks. The final code I used is as follows:

Sub ClearApplicationControls()

Application.ScreenUpdating = False

With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
.DisplayHeadings = False
.WindowState = xlMaximized
End With

Dim OneBar As CommandBar
barcount = CommandBars.Count
On Error Resume Next
For bars = 1 To barcount
CommandBars.Item(bars).Enabled = False
Next bars
On Error GoTo 0

With Application
.DisplayFullScreen = False
.DisplayFormulaBar = False
.CommandBars("Worksheet Menu Bar").Enabled = True
End With

Application.ScreenUpdating = True

End Sub

If I just set the "CommandBars.Item(bars).Enabled = True" then it fails. I'm
guessing something would be required within a "before_close" event?
Sorry to be a pest.
Sandy

"Joel" wrote in message
...
Sandy I don't think the OneBar.Visible = False is working. The On Error
statement is bypassing the statement and doing nothing.

"Sandy" wrote:

Hi Barb
I can't explain this but it suddenly decided to do???
I'm unaware of having made any other change - Strange.
I'll take your point on board about not needing the Sheets("Data Input")
part though - thank you
Sandy

"Barb Reinhardt" wrote in
message
...
Is it running at all? If not, you may have somehow set

Application.EnableEvents = FALSE

and not reset it back to TRUE.

In the Immediate window, thpe
Application.EnableEvents = TRUE

Go to another worksheet and then reactivate the DataInput sheet.

If this

Private Sub Worksheet_Activate()

Sheets("Data Input").Unprotect Password:="********"

ClearApplicationControls

Sheets("Data Input").Protect Password:="********"

End Sub


Is in the Data INput worksheet code, you don't need the Sheets("Data
Input"). part


"Sandy" wrote:

The following doesn,t work and I have no idea why - any suggestions?
I am assuming the code should run when the worksheet "Data Input" is
selected.

'Code in Sheet1 "Data Input"
Private Sub Worksheet_Activate()

Sheets("Data Input").Unprotect Password:="********"

ClearApplicationControls

Sheets("Data Input").Protect Password:="********"

End Sub

'Code in Module2
Sub ClearApplicationControls()

Application.ScreenUpdating = False

With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayWorkbookTabs = True
.DisplayHeadings = False
.WindowState = xlMaximized
End With

Dim OneBar As CommandBar
On Error Resume Next
For Each OneBar In CommandBars
OneBar.Visible = False
Next
On Error GoTo 0

With Application
.DisplayFullScreen = False
.DisplayFormulaBar = False
End With

Application.ScreenUpdating = True

End Sub









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro not showing in Tools/Macro/Macros yet show up when I goto VBA editor [email protected] Excel Programming 2 March 30th 07 07:48 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 07:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"