Error running simple command

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following function which generates "Object defined" error (please
correct for line wrapping):

Public Function LockWindowSize(argLock As Boolean)
If argLock = True Then ActiveWindow.EnableResize = False Else
ActiveWindow.EnableResize = True
End Function

Can someone fix this for me? I am attempting to disable the currently active
window from being resized. Thanks much in advance.
 
Hmmm...it works for me. How are you calling it?

Note that you can make it a bit shorter:

Public Function LockWindowSize(argLock As Boolean)
ActiveWindow.EnableResize = Not argLock
End Function
 
I switched to yours as follows:

Public Function LockWindowSize(argLock As Boolean)
ActiveWindow.EnableResize = Not argLock
End Function

I call it as follows: Call LockWindowSize(True)
That is all I have in a "Test" subroutine.

And I still get the error (Application defined or object defined error) and
the "ActiveWindow.EnableResize" line is highlighted.

Any ideas? I get the same error when running either from the VBE or from the
worksheet.
 
I get that error if the Window is maximized. Make sure you window is not
maximized. (also, I assume the workbook is not protected).
 
That's it! Thanks!

Tom Ogilvy said:
I get that error if the Window is maximized. Make sure you window is not
maximized. (also, I assume the workbook is not protected).
 
No, it was maximized...I assumed that the function would work with the window
in any state; I just modified it so that it changes the state to "Normal"
before attempting to lock it.

BTW, is it possible to do the same thing with the application window (as
opposed to the workbook)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top