Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

VBA Macros in Excel 2007


  • Please log in to reply

#1
Jonesey

Jonesey

    Member

  • Member
  • PipPipPip
  • 335 posts
We have recently upgraded all of our workstations to Office 2007 which includes Excel and Visual Basic 6.5

I have a problem with a very short, simple piece of code which runs perfectly in certain parts of the application, but not in others.

The code in question is the command to turn on/off screen updating:

Application.ScreenUpdating = True

or

Application.ScreenUpdating = False

This method works fine in most parts of my code.
Where it fails is when it's part of a routine attached to the activation scetion of a form, and is called a SECOND time from the main macro. The FIRST call is made without error.

The error message I get is: Method 'ScreenUpdating' of object '_Application' failed

The form itself is running in Non Modal state


Does anyone have a clue how I can correct this error?

It didn't manifest itself at all in previous version of Excel.


Many thanks,


Jonesey.


Edit toadd:

Stangely, when editing withing the userform, VB's predictive text actually suggests the option "ScreenUpdating" as soon as I type in application.sc - selecting the option then causes the editor to suggest True or False as alternatives.

VB seems to instinctively KNOW that what I'm typing is correct, it also passes the "Compile VBA project" test, but still throws it up as an error when run


Weird eh?

Edited by Jonesey, 17 November 2009 - 08:15 AM.

  • 0

Advertisements


#2
Vino Rosso

Vino Rosso

    Visiting Staff

  • Visiting Consultant
  • 235 posts
Wouldn't be anything to do with the particular form that's active when the code is called? Perhaps different properties?

Weird... defo!
  • 0

#3
Jonesey

Jonesey

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 335 posts
Hi Vino.

This one's got me baffled for sure.

The only temporary solution I've applied so far is to insert an On Error Resume Next statement.

The form itself only has a few lines of code, it's a progress box which shows the User exactly what's running, and the code merely switches screen updating on, repaints the form then switches screen updating off.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP