Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果我将VBA设置为新对象,它将被删除_Vba_Pointers - Fatal编程技术网

如果我将VBA设置为新对象,它将被删除

如果我将VBA设置为新对象,它将被删除,vba,pointers,Vba,Pointers,所以我每次通过循环时都会设置一个新的InternetExplorermedium。否则,我会得到一个无法识别接口的错误。我想知道我是否可以以及如何销毁以前的指针,或者这是否是一种很好的做法。 谢谢这在VBA中并没有那么糟糕。你可以在IE之后设置IE=Nothing。如果你想完全消除下一次迭代之前留下的任何引用,请退出。我不相信在这种情况下会有多大区别,因为IE.Quit无论如何都会让对象被遗忘 While Not code_Download = 0 'code_Download = 0

所以我每次通过循环时都会设置一个新的InternetExplorermedium。否则,我会得到一个无法识别接口的错误。我想知道我是否可以以及如何销毁以前的指针,或者这是否是一种很好的做法。
谢谢

这在VBA中并没有那么糟糕。你可以在IE之后设置IE=Nothing。如果你想完全消除下一次迭代之前留下的任何引用,请退出。我不相信在这种情况下会有多大区别,因为IE.Quit无论如何都会让对象被遗忘

While Not code_Download = 0     'code_Download = 0 --> CORRECT
    If delay < 30000 Then       
        delay = delay + 2000
    Else
        MsgBox "Delay too long"
        CREATEtemp_fileXML = False
        Exit Function
    End If
    Set IE = New InternetExplorerMedium ' <<<<<<<<<
    IE.Navigate wURL
    Sleep delay
    IE.Quit
    code_Download = URLDownloadToFile(0, wURL, temp_fileXML, 0, 0)