Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default weird focus problem

Application.ScreenUpdating = False
set wsA = Activesheet
Set ws = ActiveWorkbook.Worksheets("Input")
ws.Activate
ws.EnableSelection = xlUnlockedCells
ws.Protect UserInterfaceOnly:=True
wsA.Activate
Application.ScreenUpdating = True


Regards,
Tom Ogilvy


"Taher Baderkhan" wrote in message
...
Hi,

I am using a worksheet which I called "Input" as a
form. I am allowing the user to input data only in the
cells that are unlocked. I am protecting the worksheet on
initialization of the workbook using the following VBA
code:

Set ws = ActiveWorkbook.Worksheets("Input")
ws.EnableSelection = xlUnlockedCells
ws.Protect UserInterfaceOnly:=True

if the user opens up the workbook and the "Input"
worksheet is the active sheet then everything works as
expected. However, if the active sheet is not the "Input"
worksheet and then through the code I attempt to activate
the "Input" sheet and select any cell then the focus
border seems to either disappear or freeze. It does not
matter whether the cell I am attempting to select is
locked or not. If I run the code that set the protection
for the "Input" sheet again the focus problems gets
fixed. If I activate another sheet and then reactivate
the "Input" sheet through the code (basically, trying to
regenerate the problem) the focus seems to work just fine.
I have realized that this problem exists only when you try
it the first time. To regenerate the problem I had to shut
down excel and reopen the workbook.

I tried to play with the UseInterfaceOnly by trying
different combinations but the problem seemed to persist.

The workaround I found Thus far is to run
ws.EnableSelection = xlNoRestrictions, Activate
the "Input" sheet and then run
ws.EnableSelection = xlUnlockedCells. Is there any better
solution?

Taher



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
weird problem WarrenK Setting up and Configuration of Excel 0 June 5th 09 05:46 PM
Weird Problem Gaurav[_2_] Excel Worksheet Functions 4 December 17th 07 04:27 PM
cmdbarmenu focus problem pjbur2005 via OfficeKB.com Excel Worksheet Functions 2 January 28th 07 02:44 AM
Weird Problem Patrick Excel Worksheet Functions 4 March 28th 05 02:29 AM
weird focus problem Ron de Bruin Excel Programming 0 August 8th 03 03:54 PM


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