ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error running simple command (https://www.excelbanter.com/excel-programming/320056-error-running-simple-command.html)

quartz[_2_]

Error running simple command
 
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.


JE McGimpsey

Error running simple command
 
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


In article ,
quartz wrote:

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.


quartz[_2_]

Error running simple command
 
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.


"JE McGimpsey" wrote:

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


In article ,
quartz wrote:

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.



Tom Ogilvy

Error running simple command
 
I get that error if the Window is maximized. Make sure you window is not
maximized. (also, I assume the workbook is not protected).

--
Regards,
Tom Ogilvy


"quartz" wrote in message
...
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.


"JE McGimpsey" wrote:

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


In article ,
quartz wrote:

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.





JE McGimpsey

Error running simple command
 
Is the workbook protected?

In article ,
quartz wrote:

Any ideas? I get the same error when running either from the VBE or from the
worksheet.


quartz[_2_]

Error running simple command
 
That's it! Thanks!

"Tom Ogilvy" wrote:

I get that error if the Window is maximized. Make sure you window is not
maximized. (also, I assume the workbook is not protected).

--
Regards,
Tom Ogilvy


"quartz" wrote in message
...
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.


"JE McGimpsey" wrote:

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


In article ,
quartz wrote:

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.





quartz[_2_]

Error running simple command
 
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)?

"JE McGimpsey" wrote:

Is the workbook protected?

In article ,
quartz wrote:

Any ideas? I get the same error when running either from the VBE or from the
worksheet.




All times are GMT +1. The time now is 05:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com