Access denied error when resizing a HTA Print
Written by Winfred DeKreij   

When I resized a HTA with the following code:

 Sub Window_onLoad
     window.resizeTo 500,200
End Sub

I came across the following error:

Access Denied
Code: 0
Do you want to continue running scripts on this page?

This was due to a timing issue when loading the file. The Window_onLoad tries to change a property of the HTA, while the HTA is not completely loaded yet. You can solve this problem by adding a short timeout like this:

Sub Window_onLoad
Window.SetTimeout "Window.ResizeTo 500, 200", 500
End Sub

The last "500" here is the time it waits before executing the code.

Image of the error message:

That no bug, that feature MS security :)
1 Monday, 23 February 2009 17:56
Shaman
Your have smile, but
http://technet.microsoft.com
KB904947

MS recomend use IHTMLWindow2, but I dont know how it use in HTA

Add your comment

Your name:
Your website:
Subject:
Comment:
  The word for verification. Lowercase letters only with no spaces.
Word verification: