Hey, im trying to run this code and keep running into "Specified cast is not valid" for the line with Temp.document. etc.

It is allowing me to access all of IE's properties except for parentWindow. Im not sure what to do here. Does anyone have any ideas?

a Code:
  1. Public Class Form1
  2.  
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         BackgroundWorker1.RunWorkerAsync()
  5.     End Sub
  6.  
  7.     Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
  8.         Dim Temp As Object
  9.         Temp = CreateObject("InternetExplorer.Application")
  10.         Temp.Visible = True
  11.         Temp.Navigate("http://www.google.com")
  12.         Do Until Temp.ReadyState = 4
  13.         Loop
  14.         'MsgBox(Temp.document.body.innerHtml) 'this works but parentwindow doesnt
  15.         Temp.document.parentWindow.execScript("alert('test')")
  16.     End Sub
  17. End Class