Access denied error when resizing a HTA
- Details
- Category: VB Scripting
- Written by Winfred de Kreij
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:

