用VB创建一个IE对象,然后调用它的方法,怎么总出自动化错误?改怎样解决?
我的代码如下:
Dim IEiVault As Object
Dim mhwndIE As Long
Dim a As Long, Visible
Set IEiVault = CreateObject("InternetExplorer.Application")
mhwndIE = IEiVault.Application.hWnd
IEiVault.MenuBar = False
IEiVault.StatusBar = True
IEiVault.AddressBar = True
ShowWindow mhwndIE, SW_SHOWNORMAL
IEiVault.Navigate http://www.tom.com当调用Navigate时,就会出现这个错误!为什么?

解决方案 »

  1.   

    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Private Const SW_SHOWNORMAL = 1Private Sub Command1_Click()
    Dim IEiVault As Object
    Dim mhwndIE As Long
    Dim a As Long, Visible
    Set IEiVault = CreateObject("InternetExplorer.Application")
    mhwndIE = IEiVault.Application.hwnd
    IEiVault.MenuBar = False
    IEiVault.StatusBar = True
    IEiVault.AddressBar = True
    ShowWindow mhwndIE, SW_SHOWNORMAL
    IEiVault.Navigate "http://www.tom.com"
    End Sub
      

  2.   

    同意一楼。。
    http://www.tom.com是字符串,要加引号的~~
      

  3.   

    晕!!http://www.tom.com,我是加引号的,这里忘写了!呵~~不好意思!!当调用Navigate时,就会出现这个错误!