Is it Application.ScreenUpdating or Something Else ?

Farah

Board Regular
Joined
Oct 4, 2005
Messages
98
Hello,

I have a code, which send keys for Alt+F11, while it is doing so, it shows the Alt+F11 Screen. I do not want it to be shown, what exactly can i do to keep it on the Excel sheet and take the actions.

Regards,
Farah
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

S.H.A.D.O.

Well-known Member
Joined
Sep 6, 2005
Messages
1,915
Hi Farah,

Place ...
Application.ScreenUpdating = False
... at the Beginning of the Code, and ...
Application.ScreenUpdating = True
... Before the End Sub.

Hope this Helps.
All the Best.
SHADO
 
Upvote 0

tusharm

MrExcel MVP
Joined
May 28, 2002
Messages
11,029
SHADO has already given you one option, but since you were already considering ScreenUpdating, wouldn't it have been quicker for you to try it rather than ask about it and wait until somone responds?

Farah said:
Hello,

I have a code, which send keys for Alt+F11, while it is doing so, it shows the Alt+F11 Screen. I do not want it to be shown, what exactly can i do to keep it on the Excel sheet and take the actions.

Regards,
Farah
 
Upvote 0

Farah

Board Regular
Joined
Oct 4, 2005
Messages
98
Hello tushar,

i tried ScreenUpdating = False in the beginning of the code and Screenupdating = True before the End Sub, it still go to Alt+F11 Screen and i think, it is due to a line, 'DoEvents' maybe :wink: , or due to something else. :unsure:

I even tried, Application.EnableEvents = False & True etc. didn't work as well.

Thank you for your help.

Warm Regards,
Farah
 
Upvote 0

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
ADVERTISEMENT
Can you post your code?

It might be easier if everyone saw what you were trying to do.

By its nature, ALT+F11 is going to open the VBE, but that's not necessarily necessary to interact with it. Check Chip Pearson's site for Programming to the VBE for some leads.

Hope that helps,

Smitty
 
Upvote 0

Farah

Board Regular
Joined
Oct 4, 2005
Messages
98
Hi,

Here is the code:

Code:
 Sub Farah()
Application.ScreenUpdating = False

' OPEN VB EDITOR
        Application.SendKeys "%{F11}", True
        
       Application.Wait Now + TimeValue("00:00:01")
        ' TOOLS
        Application.SendKeys "%T", True
Application.Wait Now + TimeValue("00:00:01")
        ' PROJECT PROPERTIES
        Application.SendKeys "E", True
Application.Wait Now + TimeValue("00:00:01")
        Application.SendKeys "fa22(+-)74ed"
Application.Wait Now + TimeValue("00:00:01")
        
        Application.SendKeys "~", True ' ENTER
Application.Wait Now + TimeValue("00:00:01")
       Application.SendKeys "~", True         ' ENTER
       Application.Wait Now + TimeValue("00:00:01")
        ' CLOSE THE EDITOR.
        Application.SendKeys "%FC"
        DoEvents
   
Set VBComps = ActiveWorkbook.VBProject.VBComponents
Application.Wait Now + TimeValue("00:00:01")
For Each VBComp In VBComps
Application.Wait Now + TimeValue("00:00:01")
   Select Case VBComp.Type
      Case vbext_ct_StdModule, vbext_ct_MSForm, _
            vbext_ct_ClassModule
         VBComps.Remove VBComp
      Case Else
      DoEvents
         With VBComp.CodeModule
            .DeleteLines 1, .CountOfLines
         End With
   End Select
Next VBComp
DoEvents
Application.ScreenUpdating = True

End Sub
 
Upvote 0

XLGibbs

Well-known Member
Joined
Feb 25, 2005
Messages
2,446
ADVERTISEMENT
I am not 100% certain, but I think the send keys will cause automatically turn screenupdating back on.
 
Upvote 0

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,367
Office Version
  1. 365
Platform
  1. Windows
Farah

Are you using this code to open a protected project and then delete all the code in it?

If you are I would say this is not a very good way to be going about things.

Why do you want to delete the code in the first place?
 
Upvote 0

Tazguy37

MrExcel MVP
Joined
May 28, 2004
Messages
4,237
If you do indeed want to add/delete code in the VBE (by way of code) you should have a look at Chip Pearson's contributions here.

Hope that helps!

P.S. Please read the page carefully, to save yourself a lot of potential grief...

NOTE: In all versions of Excel, the VBProject must not be protected. If it is, these procedures will fail. In Excel 2002, you must have "Trust Access To Visual Basic Project" enabled. To enable this setting, go to the Tools menu in Excel, choose Macros, Security, then the "Trusted Sources" tab, and put a check next to "Trust Access To Visual Basic Project". Otherwise, you will get errors.
 
Upvote 0

Forum statistics

Threads
1,195,720
Messages
6,011,292
Members
441,599
Latest member
Jribas

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top