Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default Eliminate Screen Flashing

I have an application that is composed of several add-ins that runs under XL97 - XL2003 because of the diversity of the user base. All of the add-ins are developed, compiled and saved under XL97.

I've found out the hard way that non-XL97 users sometimes get run-time errors because of where the add-ins were compiled. To address this problem, I've got initialization code in my main add-in that checks the XL version and if its not XL97 it dynamically recompiles all of the add-ins including itself. Happily this resolves the run-time errors.

Unfortunately, it causes some screen flashing during the recompilation. Normally this screen flashing is annoying but bearable but when Excel and the application are being served up via Citrix the screen flashing is really gross.

The code that does the recompile looks like this:

Set Book = Workbooks(BookName) ' Find our workbook/xla
With Application.VBE
If Err.Number = 0 And Not Book Is Nothing Then
If LCase(BookName) = LCase(Book.name) Then
On Error GoTo 0
' Make one of our components visible in the VBE
..VBProjects(Book.VBProject.name).VBComponents(1). CodeModule.CodePane.Show
name = .VBProjects(Book.VBProject.name).name
' Find the Compile toolbar button.
With .CommandBars.FindControl(ID:=578)
If Mid(.caption, 10) = name Then
' Execute the compile if possible.
If .enabled = True Then
.Execute
DoEvents
CompileBook = True
End If
Else
LogIt "Not compiling workbook " & BookName & " but " & .caption
End If
End With
..VBProjects(Book.VBProject.name).VBComponents(1). CodeModule.CodePane.Window.Close
End If
End If
On Error GoTo 0
End With

The challenge is to get the focus to the correct VBA project without flashing the screen. As you can see, my code uses the .Show method of the CodePane object to accomplish this. I've tried using CodePane.Window.Visible = True but I've found it doesn't reliably set the focus to the desired project and so the wrong project gets compiled. .CodePane.Window.SetFocus seems to work as well as .Show but doesn't improve on the screen flashing.

The calls to the routine that perform the dynamic recompilation are bracketed by code that tries to freeze both the Excel and VBE windows. This code looks like this:

Application.ScreenUpdating = False
hWnd = myMainWhnd ' Get a handle to the application window
If hWnd < 0 Then SendMessage hWnd, WM_SETREDRAW, -CLng(False), 0& ' Freeze the main Excel window
DoEvents ' Give it a chance to read the message
hWnd = myVBEWhnd ' Get a handle to the VBE window
If hWnd < 0 Then LockWindowUpdate hWnd ' And lock it too

Without this code, the screen flashing is even worse than I described above.

Other things I've tried include:

- Minimizing the VBE .VBE.MainWindow.WindowState = vbext_ws_Minimize.

- Making the VBE really small application.VBE.MainWindow.Width & .Height = 0

- Looping through the VBE and closing all of its windows.

And as you might correctly guess, since I'm here, none of these things helped.

So I'm either looking for a different way to reliably dynamically recompile my various add-ins that doesn't cause the screen flash or a better way to suppress the screen flashing.

TIA for any suggestions.

josh




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Eliminate Screen Flashing

Try putting this code at the beginning of your recompile code:

Application.ScreenUpdating = False

and at the end of it

Application.ScreenUpdating = True

"Josh Sale" wrote:

I have an application that is composed of several add-ins that runs under XL97 - XL2003 because of the diversity of the user base. All of the add-ins are developed, compiled and saved under XL97.

I've found out the hard way that non-XL97 users sometimes get run-time errors because of where the add-ins were compiled. To address this problem, I've got initialization code in my main add-in that checks the XL version and if its not XL97 it dynamically recompiles all of the add-ins including itself. Happily this resolves the run-time errors.

Unfortunately, it causes some screen flashing during the recompilation. Normally this screen flashing is annoying but bearable but when Excel and the application are being served up via Citrix the screen flashing is really gross.

The code that does the recompile looks like this:

Set Book = Workbooks(BookName) ' Find our workbook/xla
With Application.VBE
If Err.Number = 0 And Not Book Is Nothing Then
If LCase(BookName) = LCase(Book.name) Then
On Error GoTo 0
' Make one of our components visible in the VBE
..VBProjects(Book.VBProject.name).VBComponents(1). CodeModule.CodePane.Show
name = .VBProjects(Book.VBProject.name).name
' Find the Compile toolbar button.
With .CommandBars.FindControl(ID:=578)
If Mid(.caption, 10) = name Then
' Execute the compile if possible.
If .enabled = True Then
.Execute
DoEvents
CompileBook = True
End If
Else
LogIt "Not compiling workbook " & BookName & " but " & .caption
End If
End With
..VBProjects(Book.VBProject.name).VBComponents(1). CodeModule.CodePane.Window.Close
End If
End If
On Error GoTo 0
End With

The challenge is to get the focus to the correct VBA project without flashing the screen. As you can see, my code uses the .Show method of the CodePane object to accomplish this. I've tried using CodePane.Window.Visible = True but I've found it doesn't reliably set the focus to the desired project and so the wrong project gets compiled. .CodePane.Window.SetFocus seems to work as well as .Show but doesn't improve on the screen flashing.

The calls to the routine that perform the dynamic recompilation are bracketed by code that tries to freeze both the Excel and VBE windows. This code looks like this:

Application.ScreenUpdating = False
hWnd = myMainWhnd ' Get a handle to the application window
If hWnd < 0 Then SendMessage hWnd, WM_SETREDRAW, -CLng(False), 0& ' Freeze the main Excel window
DoEvents ' Give it a chance to read the message
hWnd = myVBEWhnd ' Get a handle to the VBE window
If hWnd < 0 Then LockWindowUpdate hWnd ' And lock it too

Without this code, the screen flashing is even worse than I described above.

Other things I've tried include:

- Minimizing the VBE .VBE.MainWindow.WindowState = vbext_ws_Minimize.

- Making the VBE really small application.VBE.MainWindow.Width & .Height = 0

- Looping through the VBE and closing all of its windows.

And as you might correctly guess, since I'm here, none of these things helped.

So I'm either looking for a different way to reliably dynamically recompile my various add-ins that doesn't cause the screen flash or a better way to suppress the screen flashing.

TIA for any suggestions.

josh




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default Eliminate Screen Flashing

Thanks Rich. However as I showed in the code included in my posting, I'm
already doing that.

josh




"Rich J" wrote in message
...
Try putting this code at the beginning of your recompile code:

Application.ScreenUpdating = False

and at the end of it

Application.ScreenUpdating = True

"Josh Sale" wrote:

I have an application that is composed of several add-ins that runs under
XL97 - XL2003 because of the diversity of the user base. All of the
add-ins are developed, compiled and saved under XL97.

I've found out the hard way that non-XL97 users sometimes get run-time
errors because of where the add-ins were compiled. To address this
problem, I've got initialization code in my main add-in that checks the
XL version and if its not XL97 it dynamically recompiles all of the
add-ins including itself. Happily this resolves the run-time errors.

Unfortunately, it causes some screen flashing during the recompilation.
Normally this screen flashing is annoying but bearable but when Excel and
the application are being served up via Citrix the screen flashing is
really gross.

The code that does the recompile looks like this:

Set Book = Workbooks(BookName) ' Find our workbook/xla
With Application.VBE
If Err.Number = 0 And Not Book Is Nothing Then
If LCase(BookName) = LCase(Book.name) Then
On Error GoTo 0
' Make one of our components visible in the VBE

..VBProjects(Book.VBProject.name).VBComponents(1). CodeModule.CodePane.Show
name = .VBProjects(Book.VBProject.name).name
' Find the Compile toolbar button.
With .CommandBars.FindControl(ID:=578)
If Mid(.caption, 10) = name Then
' Execute the compile if possible.
If .enabled = True Then
.Execute
DoEvents
CompileBook = True
End If
Else
LogIt "Not compiling workbook " & BookName & " but "
& .caption
End If
End With

..VBProjects(Book.VBProject.name).VBComponents(1). CodeModule.CodePane.Window.Close
End If
End If
On Error GoTo 0
End With

The challenge is to get the focus to the correct VBA project without
flashing the screen. As you can see, my code uses the .Show method of
the CodePane object to accomplish this. I've tried using
CodePane.Window.Visible = True but I've found it doesn't reliably set the
focus to the desired project and so the wrong project gets compiled.
.CodePane.Window.SetFocus seems to work as well as .Show but doesn't
improve on the screen flashing.

The calls to the routine that perform the dynamic recompilation are
bracketed by code that tries to freeze both the Excel and VBE windows.
This code looks like this:

Application.ScreenUpdating = False
hWnd = myMainWhnd ' Get a handle to the application window
If hWnd < 0 Then SendMessage hWnd, WM_SETREDRAW, -CLng(False), 0&
' Freeze the main Excel window
DoEvents ' Give it a chance to read the message
hWnd = myVBEWhnd ' Get a handle to the VBE window
If hWnd < 0 Then LockWindowUpdate hWnd ' And lock it too

Without this code, the screen flashing is even worse than I described
above.

Other things I've tried include:

- Minimizing the VBE .VBE.MainWindow.WindowState = vbext_ws_Minimize.

- Making the VBE really small application.VBE.MainWindow.Width & .Height
= 0

- Looping through the VBE and closing all of its windows.

And as you might correctly guess, since I'm here, none of these things
helped.

So I'm either looking for a different way to reliably dynamically
recompile my various add-ins that doesn't cause the screen flash or a
better way to suppress the screen flashing.

TIA for any suggestions.

josh






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Eliminate Screen Flashing

I didn't look thru the whole code you posted. I had that problem when the
application.screenupdating = False was in one of my subroutines. If the
subroutine is being called many times during execution then depending where
.... = True is you might be causing the flashing. I moved the line to the
main calling routine and the screen does one flash and the changes are there.

"Josh Sale" wrote:

Thanks Rich. However as I showed in the code included in my posting, I'm
already doing that.

josh




"Rich J" wrote in message
...
Try putting this code at the beginning of your recompile code:

Application.ScreenUpdating = False

and at the end of it

Application.ScreenUpdating = True

"Josh Sale" wrote:

I have an application that is composed of several add-ins that runs under
XL97 - XL2003 because of the diversity of the user base. All of the
add-ins are developed, compiled and saved under XL97.

I've found out the hard way that non-XL97 users sometimes get run-time
errors because of where the add-ins were compiled. To address this
problem, I've got initialization code in my main add-in that checks the
XL version and if its not XL97 it dynamically recompiles all of the
add-ins including itself. Happily this resolves the run-time errors.

Unfortunately, it causes some screen flashing during the recompilation.
Normally this screen flashing is annoying but bearable but when Excel and
the application are being served up via Citrix the screen flashing is
really gross.

The code that does the recompile looks like this:

Set Book = Workbooks(BookName) ' Find our workbook/xla
With Application.VBE
If Err.Number = 0 And Not Book Is Nothing Then
If LCase(BookName) = LCase(Book.name) Then
On Error GoTo 0
' Make one of our components visible in the VBE

..VBProjects(Book.VBProject.name).VBComponents(1). CodeModule.CodePane.Show
name = .VBProjects(Book.VBProject.name).name
' Find the Compile toolbar button.
With .CommandBars.FindControl(ID:=578)
If Mid(.caption, 10) = name Then
' Execute the compile if possible.
If .enabled = True Then
.Execute
DoEvents
CompileBook = True
End If
Else
LogIt "Not compiling workbook " & BookName & " but "
& .caption
End If
End With

..VBProjects(Book.VBProject.name).VBComponents(1). CodeModule.CodePane.Window.Close
End If
End If
On Error GoTo 0
End With

The challenge is to get the focus to the correct VBA project without
flashing the screen. As you can see, my code uses the .Show method of
the CodePane object to accomplish this. I've tried using
CodePane.Window.Visible = True but I've found it doesn't reliably set the
focus to the desired project and so the wrong project gets compiled.
.CodePane.Window.SetFocus seems to work as well as .Show but doesn't
improve on the screen flashing.

The calls to the routine that perform the dynamic recompilation are
bracketed by code that tries to freeze both the Excel and VBE windows.
This code looks like this:

Application.ScreenUpdating = False
hWnd = myMainWhnd ' Get a handle to the application window
If hWnd < 0 Then SendMessage hWnd, WM_SETREDRAW, -CLng(False), 0&
' Freeze the main Excel window
DoEvents ' Give it a chance to read the message
hWnd = myVBEWhnd ' Get a handle to the VBE window
If hWnd < 0 Then LockWindowUpdate hWnd ' And lock it too

Without this code, the screen flashing is even worse than I described
above.

Other things I've tried include:

- Minimizing the VBE .VBE.MainWindow.WindowState = vbext_ws_Minimize.

- Making the VBE really small application.VBE.MainWindow.Width & .Height
= 0

- Looping through the VBE and closing all of its windows.

And as you might correctly guess, since I'm here, none of these things
helped.

So I'm either looking for a different way to reliably dynamically
recompile my various add-ins that doesn't cause the screen flash or a
better way to suppress the screen flashing.

TIA for any suggestions.

josh







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 177
Default Eliminate Screen Flashing

Right, as I tried to say in my original post, all of the recompile logic is
contained within code designed to eliminate the screen flashing ...
including the manipulation of Application.ScreenUpdating.



"Rich J" wrote in message
...
I didn't look thru the whole code you posted. I had that problem when the
application.screenupdating = False was in one of my subroutines. If the
subroutine is being called many times during execution then depending
where
... = True is you might be causing the flashing. I moved the line to the
main calling routine and the screen does one flash and the changes are
there.

"Josh Sale" wrote:



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
Screen flashing teepee[_3_] Excel Discussion (Misc queries) 0 November 26th 08 12:20 AM
Screen flashing why? Chet Excel Discussion (Misc queries) 1 May 16th 06 08:25 PM
How to update a control without screen flashing Chaplain Doug Excel Programming 4 May 20th 05 07:25 PM
flashing screen Paul Excel Programming 2 March 9th 05 01:59 PM
Eliminate screen flashing while running a macro using VBA in Microsoft Excel. abbeville Excel Programming 1 May 21st 04 02:11 PM


All times are GMT +1. The time now is 09:23 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"