Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EXCEL code problem

Status
Not open for further replies.

wuwang

Programmer
May 16, 2001
48
US
Hi,

I created a form in EXCEL 2000 and I had code to put the form in the middle of screen. The code ran ok in 2000 but it has problem in EXCEL 97. The error message is " Object doesn't support this property or method".

How to make the code change to fit both EXCEL 97 and EXCEL 2000?

Here is my code:

frm_Main.Left = (ActiveWorkbook.Width - frm_Main.Width) / 2
frm_Main.Top = (ActiveWorkbook.Height - frm_Main.Height) / 2

Thank you in advance

 
Maybe try this. . .

frm_Main.Left = (Application.UsableWidth - frm_Main.Width) / 2
frm_Main.Top = (Application.UsableHeight - frm_Main.Height) / 2
 
Thank you for your input.
I tried it in 97 and found it works only when EXCEL worksheet is widely open. If the size of worksheet shrinked then the form won't be in the middle of the screen. If there is any way in 97 to force the form in the middle of the screen regardless the size of worksheet?

Thanks again
 
Looking at the couple of questions you have asked, Could I suggest that you work the other way around, that is write your code in Excel 97 VBA then use it with Excel 2000. The reason being Excel 2000 is backwards compatible (mostly) but you do not get forwards compatibility.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top