#1   Report Post  
Posted to microsoft.public.excel.misc
dim dim is offline
external usenet poster
 
Posts: 123
Default Screen Flicker

Hi folks,

When I run a macro I've disabled some screen flicker using
ScreenUpdating=False which works fine. But part of my macro is to open then
close another workbook, and when it opens it automatically displays for a
second until it closes again. Is there any way I can stop this?

Maybe there's some sort of option in Excel that doesn't open new workbooks
as the front window and I could include the selection of this option as part
of my macro.....

Any ideas are much appreciated?
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6,582
Default Screen Flicker

If screen updating is set to false, you should not see a workbook opening
and closing. What version of Excel?

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"dim" wrote in message
...
Hi folks,

When I run a macro I've disabled some screen flicker using
ScreenUpdating=False which works fine. But part of my macro is to open
then
close another workbook, and when it opens it automatically displays for a
second until it closes again. Is there any way I can stop this?

Maybe there's some sort of option in Excel that doesn't open new workbooks
as the front window and I could include the selection of this option as
part
of my macro.....

Any ideas are much appreciated?
Thanks



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default Screen Flicker

ScreenUpdating should do it. I'm not sure why it wouldn't. You could try the
following:

Public Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As
Long) As Long

Sub OpenWorkbook()
Dim XLHWnd As Long
On Error GoTo ErrH:
XLHWnd = Application.Hwnd
LockWindowUpdate XLHWnd
Workbooks.Open "C:\Book1.xls"
ErrH:
''''''''''''''''''''''''''''
' Be SURE (!!) that
' LockWindowUpdate 0& gets
' called regardless of any
' error.
''''''''''''''''''''''''''''
LockWindowUpdate 0&
End Sub

Be SURE (!) to call LockWindowUpdate passing it a 0, regardless of whatever
path code execution takes or whatever errors may occur.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)



"dim" wrote in message
...
Hi folks,

When I run a macro I've disabled some screen flicker using
ScreenUpdating=False which works fine. But part of my macro is to open
then
close another workbook, and when it opens it automatically displays for a
second until it closes again. Is there any way I can stop this?

Maybe there's some sort of option in Excel that doesn't open new workbooks
as the front window and I could include the selection of this option as
part
of my macro.....

Any ideas are much appreciated?
Thanks


  #4   Report Post  
Posted to microsoft.public.excel.misc
dim dim is offline
external usenet poster
 
Posts: 123
Default Screen Flicker

Jon, its Excel 2002.

Here's my code:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 27/11/2007 by D. Murphy
'
' Keyboard Shortcut: Ctrl+a
'
ScreenUpdating = False
Workbooks.Open Filename:="C:\Program Files\test\Book2.xls"
Sheets("Sheet1").Select
Rows("2:2").Select
Selection.Insert Shift:=xlDown
Windows("Book1.xls").Activate
Sheets("Sheet2").Select
Rows("2:2").Select
Selection.Copy
Windows("Book2.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWorkbook.Close
Sheets("Sheet1").Select
Range("H14").Select
Selection.ClearContents
Range("H12").Select
Selection.ClearContents
Range("H10").Select
Selection.ClearContents
End Sub

Thanks for that advice Chip, I'll try it out.

"Chip Pearson" wrote:

ScreenUpdating should do it. I'm not sure why it wouldn't. You could try the
following:

Public Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As
Long) As Long

Sub OpenWorkbook()
Dim XLHWnd As Long
On Error GoTo ErrH:
XLHWnd = Application.Hwnd
LockWindowUpdate XLHWnd
Workbooks.Open "C:\Book1.xls"
ErrH:
''''''''''''''''''''''''''''
' Be SURE (!!) that
' LockWindowUpdate 0& gets
' called regardless of any
' error.
''''''''''''''''''''''''''''
LockWindowUpdate 0&
End Sub

Be SURE (!) to call LockWindowUpdate passing it a 0, regardless of whatever
path code execution takes or whatever errors may occur.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)



"dim" wrote in message
...
Hi folks,

When I run a macro I've disabled some screen flicker using
ScreenUpdating=False which works fine. But part of my macro is to open
then
close another workbook, and when it opens it automatically displays for a
second until it closes again. Is there any way I can stop this?

Maybe there's some sort of option in Excel that doesn't open new workbooks
as the front window and I could include the selection of this option as
part
of my macro.....

Any ideas are much appreciated?
Thanks


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6,582
Default Screen Flicker

I don't know if it leads to your flickering, but there are a lot of
inefficiencies in your code. In general it is not necessary, and even not
desirable, to select each object before doing something with it.

This whole piece:

ScreenUpdating = False
Workbooks.Open Filename:="C:\Program Files\test\Book2.xls"
Sheets("Sheet1").Select
Rows("2:2").Select
Selection.Insert Shift:=xlDown
Windows("Book1.xls").Activate
Sheets("Sheet2").Select
Rows("2:2").Select
Selection.Copy
Windows("Book2.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


reduces to this:

Workbooks("Book2.xls").Sheets("Sheet1").Rows("2:2" ).Insert Shift:=xlDown
Workbooks("Book1.xls").Sheets("Sheet2").Rows("2:2" ).Copy
Workbooks("Book2.xls").Sheets("Sheet1").Rows("2:2" ).PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False,
Transpose:=False

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"dim" wrote in message
...
Jon, its Excel 2002.

Here's my code:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 27/11/2007 by D. Murphy
'
' Keyboard Shortcut: Ctrl+a
'
ScreenUpdating = False
Workbooks.Open Filename:="C:\Program Files\test\Book2.xls"
Sheets("Sheet1").Select
Rows("2:2").Select
Selection.Insert Shift:=xlDown
Windows("Book1.xls").Activate
Sheets("Sheet2").Select
Rows("2:2").Select
Selection.Copy
Windows("Book2.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWorkbook.Close
Sheets("Sheet1").Select
Range("H14").Select
Selection.ClearContents
Range("H12").Select
Selection.ClearContents
Range("H10").Select
Selection.ClearContents
End Sub

Thanks for that advice Chip, I'll try it out.

"Chip Pearson" wrote:

ScreenUpdating should do it. I'm not sure why it wouldn't. You could try
the
following:

Public Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As
Long) As Long

Sub OpenWorkbook()
Dim XLHWnd As Long
On Error GoTo ErrH:
XLHWnd = Application.Hwnd
LockWindowUpdate XLHWnd
Workbooks.Open "C:\Book1.xls"
ErrH:
''''''''''''''''''''''''''''
' Be SURE (!!) that
' LockWindowUpdate 0& gets
' called regardless of any
' error.
''''''''''''''''''''''''''''
LockWindowUpdate 0&
End Sub

Be SURE (!) to call LockWindowUpdate passing it a 0, regardless of
whatever
path code execution takes or whatever errors may occur.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)



"dim" wrote in message
...
Hi folks,

When I run a macro I've disabled some screen flicker using
ScreenUpdating=False which works fine. But part of my macro is to open
then
close another workbook, and when it opens it automatically displays for
a
second until it closes again. Is there any way I can stop this?

Maybe there's some sort of option in Excel that doesn't open new
workbooks
as the front window and I could include the selection of this option as
part
of my macro.....

Any ideas are much appreciated?
Thanks




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
List box screen flicker [email protected] Excel Discussion (Misc queries) 0 September 25th 07 02:37 PM
In Excel, how can i make text in a sigle sell flash, or flicker? Piersy Excel Discussion (Misc queries) 0 December 14th 06 04:00 AM
Prevent Excel chart flicker,when plots are linked to DDE data Cliff Allen Charts and Charting in Excel 1 September 20th 06 04:14 AM
print box opens in right screen of dual screen setup why gerrys Excel Discussion (Misc queries) 1 June 30th 06 06:47 PM
Preventing screen flicker Paul Excel Discussion (Misc queries) 2 March 15th 05 09:39 PM


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

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

About Us

"It's about Microsoft Excel"