I don't why, but you must force the 2048 flags argument to be passed as a Long data type by appending '&' to it. Also, the IE .Busy Or .ReadyState wait is only needed for the first Navigate because the code must wait until the first tab is opened before opening the new tabs. New tabs opened by the subsequent Navigates are then opened asynchronously - see http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx - and the same wait has no effect because at that point IE is ready and not busy, so the IE wait isn't needed
This works for me in IE8:
Function OpenLinks(URL1 As String, URL2 As String, URL3 As String, URL4 As String)
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate URL1, 0
While .Busy Or .ReadyState <> 4: DoEvents: Wend
.Navigate URL2, 2048&
.Navigate URL3, 2048&
.Navigate URL4, 2048&
End With
End Function
If you want to specify a variable for the Flags argument, you must declare it as Variant and append & to denote a Long value, like this:
Function OpenLinks2(URL1 As String, URL2 As String, URL3 As String, URL4 As String)
Dim IE As Object
Dim flags As Variant
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
flags = 0
.Navigate URL1, flags
While .Busy Or .ReadyState <> 4: DoEvents: Wend
flags = 2048&
.Navigate URL2, flags
.Navigate URL3, flags
.Navigate URL4, flags
End With
End Function