Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Workbook Open

Hi,

I have a workbook with a Workbook_Open procedure in the ThisWorkbook module.
Here is the code..

Private Sub Workbook_Open()

Dim wkSheet As Worksheet

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

For Each wkSheet In Worksheets
wkSheet.Protect Password:="abcdefg", _
userinterfaceonly:=True, contents:=True, _
AllowFormattingCells:=True
Next wkSheet

Call AddSheets.ProtectWkbook

MainPagepg.Activate

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

I get screen flickering each time the workbook is opened. I added the
application.screenupdating and application.calculation commands to try and
stop the flickering. The flickering still occcurs.

Do any worksheet_calculate procedures run everytime the workbook is opened
or only when something is changed? I am trying to figure out where the
flickering is coming from. Does anyone have any suggestions?
--
Thanks for your help.
Karen53
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Workbook Open

Any chance that AddSheets.ProtectWkbook turns the screenupdating off? I'd look
there first.

There are some things (pretty unusual, though) that turn screenupdating on. But
I don't see anything in your posted code that would do that.

And xl will recalc if you open a workbook that was saved in a previous version.
Could that be the problem?

Karen53 wrote:

Hi,

I have a workbook with a Workbook_Open procedure in the ThisWorkbook module.
Here is the code..

Private Sub Workbook_Open()

Dim wkSheet As Worksheet

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

For Each wkSheet In Worksheets
wkSheet.Protect Password:="abcdefg", _
userinterfaceonly:=True, contents:=True, _
AllowFormattingCells:=True
Next wkSheet

Call AddSheets.ProtectWkbook

MainPagepg.Activate

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

I get screen flickering each time the workbook is opened. I added the
application.screenupdating and application.calculation commands to try and
stop the flickering. The flickering still occcurs.

Do any worksheet_calculate procedures run everytime the workbook is opened
or only when something is changed? I am trying to figure out where the
flickering is coming from. Does anyone have any suggestions?
--
Thanks for your help.
Karen53


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Workbook Open

Hi Dave,

No, this was made on the same version of excel, so it's not a previous
version.

Here is the AddSheets.ProtectWkbook procedure...

Sub ProtectWkbook()

Dim IsProtected As Boolean

IsProtected = False

If ActiveWorkbook.ProtectStructure Then IsProtected = True

If IsProtected = False Then
ActiveWorkbook.Protect Password:=([MyPassword]), Structu=True,
Windows:=False
End If

End Sub

Just on the chance, I removed any screenupdating code on the
worksheet_calculates but the workbook still flickers on opening.
--
Thanks for your help.
Karen53


"Dave Peterson" wrote:

Any chance that AddSheets.ProtectWkbook turns the screenupdating off? I'd look
there first.

There are some things (pretty unusual, though) that turn screenupdating on. But
I don't see anything in your posted code that would do that.

And xl will recalc if you open a workbook that was saved in a previous version.
Could that be the problem?

Karen53 wrote:

Hi,

I have a workbook with a Workbook_Open procedure in the ThisWorkbook module.
Here is the code..

Private Sub Workbook_Open()

Dim wkSheet As Worksheet

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

For Each wkSheet In Worksheets
wkSheet.Protect Password:="abcdefg", _
userinterfaceonly:=True, contents:=True, _
AllowFormattingCells:=True
Next wkSheet

Call AddSheets.ProtectWkbook

MainPagepg.Activate

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

I get screen flickering each time the workbook is opened. I added the
application.screenupdating and application.calculation commands to try and
stop the flickering. The flickering still occcurs.

Do any worksheet_calculate procedures run everytime the workbook is opened
or only when something is changed? I am trying to figure out where the
flickering is coming from. Does anyone have any suggestions?
--
Thanks for your help.
Karen53


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Workbook Open

First, I'd double check at all those UDFs again for screenupdating lines. I'm
not sure why you'd have that in a UDF anyway.

I still don't see anything in the code you posted that would toggle that
screenupdating setting.

There are things built into excel that will toggle the .screenupdating setting
to off. If I remember correctly, if you call some (not sure which) functions
from the analysis toolpak, then that setting could be changed to true.

If that's the case, you have a couple of options.

1. Find those lines (pepper your code with lines like:
debug.print "some step # here " & application.screenupdating

Then run the macro and see where True shows up.

2. The other option is to use an API call that actually freezes your display.
This can be dangerous. If your code breaks before you can turn the display back
on, you'll be rebooting your pc--and losing any work that hasn't been saved.


At the top of the module:

Declare Function LockWindowUpdate Lib _
"user32" (ByVal hwndLock As Long) As Long
Declare Function FindWindowA Lib _
"user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

In your code:

Sub whatever()
'do stuff

'freeze the screen
hWnd = FindWindowA("XLMAIN", Application.Caption)
LockWindowUpdate hWnd

'do more stuff

'unfreeze the screen
LockWindowUpdate 0

'do more stuff

End sub

Remember to save your work often (in all open applications!) if you use this.
You may be rebooting more than you want. (I wouldn't use this--but I've said
this before.)

Karen53 wrote:

Hi Dave,

No, this was made on the same version of excel, so it's not a previous
version.

Here is the AddSheets.ProtectWkbook procedure...

Sub ProtectWkbook()

Dim IsProtected As Boolean

IsProtected = False

If ActiveWorkbook.ProtectStructure Then IsProtected = True

If IsProtected = False Then
ActiveWorkbook.Protect Password:=([MyPassword]), Structu=True,
Windows:=False
End If

End Sub

Just on the chance, I removed any screenupdating code on the
worksheet_calculates but the workbook still flickers on opening.
--
Thanks for your help.
Karen53

"Dave Peterson" wrote:

Any chance that AddSheets.ProtectWkbook turns the screenupdating off? I'd look
there first.

There are some things (pretty unusual, though) that turn screenupdating on. But
I don't see anything in your posted code that would do that.

And xl will recalc if you open a workbook that was saved in a previous version.
Could that be the problem?

Karen53 wrote:

Hi,

I have a workbook with a Workbook_Open procedure in the ThisWorkbook module.
Here is the code..

Private Sub Workbook_Open()

Dim wkSheet As Worksheet

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

For Each wkSheet In Worksheets
wkSheet.Protect Password:="abcdefg", _
userinterfaceonly:=True, contents:=True, _
AllowFormattingCells:=True
Next wkSheet

Call AddSheets.ProtectWkbook

MainPagepg.Activate

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

I get screen flickering each time the workbook is opened. I added the
application.screenupdating and application.calculation commands to try and
stop the flickering. The flickering still occcurs.

Do any worksheet_calculate procedures run everytime the workbook is opened
or only when something is changed? I am trying to figure out where the
flickering is coming from. Does anyone have any suggestions?
--
Thanks for your help.
Karen53


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Workbook Open

Hi Dave,

I went through again and double checked I had all of the screenupdating
statements removed. They are gone.

I added debug.prints in the Workbook Open proceudure and again before each
next Wksheet. They are all false for screenupdating.

I also added debug.prints in each of the worksheet calculates. For some
reason they run not once, but twice once the workbook open is finished. I
thought maybe it was the mainpagepg.activate so I removed it. I got the same
results.

wkbook open False
Master Page False
GL Line Items False
Gross Up False
Sum by Line Item False
First False
Jack Sparrow False
Jessica Rabbit False
Lois Lane False
James Bond False
Sherlock Holmes False
Dread Pirate Roberts False
Indiana Jones False
Austin Powers False
Last False
Maintenance False
CAM Master False
Tables False
ProtectWkbook Procedure False
MainPage Activate
Calculate Austin Powers
Calculate Dread Pirate Roberts
Calculate Indiana Jones
Calculate Jack Sparrow
Calculate James Bond
Calculate Jessica Rabbit
Calculate Lois Lane
Calculate Sherlock Holmes
Calculate Austin Powers
Calculate Dread Pirate Roberts
Calculate Indiana Jones
Calculate Jack Sparrow
Calculate James Bond
Calculate Jessica Rabbit
Calculate Lois Lane
Calculate Sherlock Holmes

There is no more code in the workbook open procedure. None of the values
have changed since the workbook was closed. Why are the calculates running,
twice yet?

Do you have any more debuging suggestions?


--
Thanks for your help.
Karen53


"Dave Peterson" wrote:

First, I'd double check at all those UDFs again for screenupdating lines. I'm
not sure why you'd have that in a UDF anyway.

I still don't see anything in the code you posted that would toggle that
screenupdating setting.

There are things built into excel that will toggle the .screenupdating setting
to off. If I remember correctly, if you call some (not sure which) functions
from the analysis toolpak, then that setting could be changed to true.

If that's the case, you have a couple of options.

1. Find those lines (pepper your code with lines like:
debug.print "some step # here " & application.screenupdating

Then run the macro and see where True shows up.

2. The other option is to use an API call that actually freezes your display.
This can be dangerous. If your code breaks before you can turn the display back
on, you'll be rebooting your pc--and losing any work that hasn't been saved.


At the top of the module:

Declare Function LockWindowUpdate Lib _
"user32" (ByVal hwndLock As Long) As Long
Declare Function FindWindowA Lib _
"user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

In your code:

Sub whatever()
'do stuff

'freeze the screen
hWnd = FindWindowA("XLMAIN", Application.Caption)
LockWindowUpdate hWnd

'do more stuff

'unfreeze the screen
LockWindowUpdate 0

'do more stuff

End sub

Remember to save your work often (in all open applications!) if you use this.
You may be rebooting more than you want. (I wouldn't use this--but I've said
this before.)

Karen53 wrote:

Hi Dave,

No, this was made on the same version of excel, so it's not a previous
version.

Here is the AddSheets.ProtectWkbook procedure...

Sub ProtectWkbook()

Dim IsProtected As Boolean

IsProtected = False

If ActiveWorkbook.ProtectStructure Then IsProtected = True

If IsProtected = False Then
ActiveWorkbook.Protect Password:=([MyPassword]), Structu=True,
Windows:=False
End If

End Sub

Just on the chance, I removed any screenupdating code on the
worksheet_calculates but the workbook still flickers on opening.
--
Thanks for your help.
Karen53

"Dave Peterson" wrote:

Any chance that AddSheets.ProtectWkbook turns the screenupdating off? I'd look
there first.

There are some things (pretty unusual, though) that turn screenupdating on. But
I don't see anything in your posted code that would do that.

And xl will recalc if you open a workbook that was saved in a previous version.
Could that be the problem?

Karen53 wrote:

Hi,

I have a workbook with a Workbook_Open procedure in the ThisWorkbook module.
Here is the code..

Private Sub Workbook_Open()

Dim wkSheet As Worksheet

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

For Each wkSheet In Worksheets
wkSheet.Protect Password:="abcdefg", _
userinterfaceonly:=True, contents:=True, _
AllowFormattingCells:=True
Next wkSheet

Call AddSheets.ProtectWkbook

MainPagepg.Activate

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

I get screen flickering each time the workbook is opened. I added the
application.screenupdating and application.calculation commands to try and
stop the flickering. The flickering still occcurs.

Do any worksheet_calculate procedures run everytime the workbook is opened
or only when something is changed? I am trying to figure out where the
flickering is coming from. Does anyone have any suggestions?
--
Thanks for your help.
Karen53

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Workbook Open

It doesn't look like you actually printed the .screenupdating status on all your
debug.print lines.

But I'm out of suggestions if you find that they're all false (before and after
each procedure).

Karen53 wrote:

Hi Dave,

I went through again and double checked I had all of the screenupdating
statements removed. They are gone.

I added debug.prints in the Workbook Open proceudure and again before each
next Wksheet. They are all false for screenupdating.

I also added debug.prints in each of the worksheet calculates. For some
reason they run not once, but twice once the workbook open is finished. I
thought maybe it was the mainpagepg.activate so I removed it. I got the same
results.

wkbook open False
Master Page False
GL Line Items False
Gross Up False
Sum by Line Item False
First False
Jack Sparrow False
Jessica Rabbit False
Lois Lane False
James Bond False
Sherlock Holmes False
Dread Pirate Roberts False
Indiana Jones False
Austin Powers False
Last False
Maintenance False
CAM Master False
Tables False
ProtectWkbook Procedure False
MainPage Activate
Calculate Austin Powers
Calculate Dread Pirate Roberts
Calculate Indiana Jones
Calculate Jack Sparrow
Calculate James Bond
Calculate Jessica Rabbit
Calculate Lois Lane
Calculate Sherlock Holmes
Calculate Austin Powers
Calculate Dread Pirate Roberts
Calculate Indiana Jones
Calculate Jack Sparrow
Calculate James Bond
Calculate Jessica Rabbit
Calculate Lois Lane
Calculate Sherlock Holmes

There is no more code in the workbook open procedure. None of the values
have changed since the workbook was closed. Why are the calculates running,
twice yet?

Do you have any more debuging suggestions?

--
Thanks for your help.
Karen53

"Dave Peterson" wrote:

First, I'd double check at all those UDFs again for screenupdating lines. I'm
not sure why you'd have that in a UDF anyway.

I still don't see anything in the code you posted that would toggle that
screenupdating setting.

There are things built into excel that will toggle the .screenupdating setting
to off. If I remember correctly, if you call some (not sure which) functions
from the analysis toolpak, then that setting could be changed to true.

If that's the case, you have a couple of options.

1. Find those lines (pepper your code with lines like:
debug.print "some step # here " & application.screenupdating

Then run the macro and see where True shows up.

2. The other option is to use an API call that actually freezes your display.
This can be dangerous. If your code breaks before you can turn the display back
on, you'll be rebooting your pc--and losing any work that hasn't been saved.


At the top of the module:

Declare Function LockWindowUpdate Lib _
"user32" (ByVal hwndLock As Long) As Long
Declare Function FindWindowA Lib _
"user32" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

In your code:

Sub whatever()
'do stuff

'freeze the screen
hWnd = FindWindowA("XLMAIN", Application.Caption)
LockWindowUpdate hWnd

'do more stuff

'unfreeze the screen
LockWindowUpdate 0

'do more stuff

End sub

Remember to save your work often (in all open applications!) if you use this.
You may be rebooting more than you want. (I wouldn't use this--but I've said
this before.)

Karen53 wrote:

Hi Dave,

No, this was made on the same version of excel, so it's not a previous
version.

Here is the AddSheets.ProtectWkbook procedure...

Sub ProtectWkbook()

Dim IsProtected As Boolean

IsProtected = False

If ActiveWorkbook.ProtectStructure Then IsProtected = True

If IsProtected = False Then
ActiveWorkbook.Protect Password:=([MyPassword]), Structu=True,
Windows:=False
End If

End Sub

Just on the chance, I removed any screenupdating code on the
worksheet_calculates but the workbook still flickers on opening.
--
Thanks for your help.
Karen53

"Dave Peterson" wrote:

Any chance that AddSheets.ProtectWkbook turns the screenupdating off? I'd look
there first.

There are some things (pretty unusual, though) that turn screenupdating on. But
I don't see anything in your posted code that would do that.

And xl will recalc if you open a workbook that was saved in a previous version.
Could that be the problem?

Karen53 wrote:

Hi,

I have a workbook with a Workbook_Open procedure in the ThisWorkbook module.
Here is the code..

Private Sub Workbook_Open()

Dim wkSheet As Worksheet

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

For Each wkSheet In Worksheets
wkSheet.Protect Password:="abcdefg", _
userinterfaceonly:=True, contents:=True, _
AllowFormattingCells:=True
Next wkSheet

Call AddSheets.ProtectWkbook

MainPagepg.Activate

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

I get screen flickering each time the workbook is opened. I added the
application.screenupdating and application.calculation commands to try and
stop the flickering. The flickering still occcurs.

Do any worksheet_calculate procedures run everytime the workbook is opened
or only when something is changed? I am trying to figure out where the
flickering is coming from. Does anyone have any suggestions?
--
Thanks for your help.
Karen53

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Workbook Open

Hi Dave,

Yes, it is running each Worksheet_Change everytime the workbook is opened.
Is there a way I can stop this?
--
Thanks for your help.
Karen53


"Dave Peterson" wrote:

Any chance that AddSheets.ProtectWkbook turns the screenupdating off? I'd look
there first.

There are some things (pretty unusual, though) that turn screenupdating on. But
I don't see anything in your posted code that would do that.

And xl will recalc if you open a workbook that was saved in a previous version.
Could that be the problem?

Karen53 wrote:

Hi,

I have a workbook with a Workbook_Open procedure in the ThisWorkbook module.
Here is the code..

Private Sub Workbook_Open()

Dim wkSheet As Worksheet

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

For Each wkSheet In Worksheets
wkSheet.Protect Password:="abcdefg", _
userinterfaceonly:=True, contents:=True, _
AllowFormattingCells:=True
Next wkSheet

Call AddSheets.ProtectWkbook

MainPagepg.Activate

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

I get screen flickering each time the workbook is opened. I added the
application.screenupdating and application.calculation commands to try and
stop the flickering. The flickering still occcurs.

Do any worksheet_calculate procedures run everytime the workbook is opened
or only when something is changed? I am trying to figure out where the
flickering is coming from. Does anyone have any suggestions?
--
Thanks for your help.
Karen53


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Workbook Open

Hi,

I added application enableevents to the Workbook Open procedure and removed
the application.enableevents = true statement from all of the
worksheet_calculate procedures and the flickering stopped. Of course now the
individual worksheets are not working correctly. How can I resolve this?
The workbook was created here at work but I did make modifications at home.
We are both V 2003 SP2. This shouldn't cause this to happen, would it?
--
Thanks for your help.
Karen53


"Dave Peterson" wrote:

Any chance that AddSheets.ProtectWkbook turns the screenupdating off? I'd look
there first.

There are some things (pretty unusual, though) that turn screenupdating on. But
I don't see anything in your posted code that would do that.

And xl will recalc if you open a workbook that was saved in a previous version.
Could that be the problem?

Karen53 wrote:

Hi,

I have a workbook with a Workbook_Open procedure in the ThisWorkbook module.
Here is the code..

Private Sub Workbook_Open()

Dim wkSheet As Worksheet

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

For Each wkSheet In Worksheets
wkSheet.Protect Password:="abcdefg", _
userinterfaceonly:=True, contents:=True, _
AllowFormattingCells:=True
Next wkSheet

Call AddSheets.ProtectWkbook

MainPagepg.Activate

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub

I get screen flickering each time the workbook is opened. I added the
application.screenupdating and application.calculation commands to try and
stop the flickering. The flickering still occcurs.

Do any worksheet_calculate procedures run everytime the workbook is opened
or only when something is changed? I am trying to figure out where the
flickering is coming from. Does anyone have any suggestions?
--
Thanks for your help.
Karen53


--

Dave Peterson

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
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
how do i open a data workbook when i open a timesheet workbook [email protected] uk Excel Discussion (Misc queries) 2 January 4th 09 04:50 PM
Open a specific workbook...find value from other open workbook and then insert cells values in cell next to it. [email protected] Excel Programming 1 May 13th 07 01:46 PM
excel 2003 saved file will not open without a blank workbook open Bob Excel Discussion (Misc queries) 4 November 11th 06 04:24 PM
How do you program so that Workbook B cannot be open unless Workbook A is open? Plus I need to validation Marcello do Guzman[_3_] Excel Programming 2 December 5th 04 06:50 AM


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

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"