How to run InternetExplorer with long URL from VB
I use VB within MS office and would like to run IE from Excel. The codes are like these:
VB Code:
urlHeader = "http://bla.blablalalal"
Set IE = CreateObject("InternetExplorer.Application")
For r = 2 To 1000 Step 1
Str = Cells(r, 2).Value
url = urlHeader & Str
IE.Navigate (url)
While (IE.ReadyState <> 4)
Application.Wait 10
Wend
sRet = IE.Document.DocumentElement.OuterHTML
'........
Next r
This works fine when len(url)=<2048, but longer url is truncated by IE. Could you give me suggestions to get around this problem? Thanks a lot.
Nanfei
Re: How to run InternetExplorer with long URL from VB
Welcome to the Forums.
Have you tried... I'm not 100% sure it has a greater limitation but its worth a try.
VB Code:
Dim oProcess As Process
Dim oPSI As New ProcessStartInfo
oPSI.FileName = "C:\Program Files\Internet Explorer\IExplore.exe"
oPSI.Arguments = "http://www.vbforums.com"
oProcess = oProcess.Start(oPSI)
Re: How to run InternetExplorer with long URL from VB
Tried your suggestion, and got an error "User-defined type not defined" at line:
Dim oProcess As Process
Is there any library I should check in the reference for these codes?
Re: How to run InternetExplorer with long URL from VB
RobDog888 is off-line so I'll field this one. The Process class is in the System.Diagnostics namespace but, although I look at my own projects and see no reference and no Import, I can still use Process unqualified. If you can't, simply import the namespace or qualify the class name. Also, without RobDog888's extra code for clarity, you could also simply try:
VB Code:
Dim myProcess As Process = Process.Start("IExplore", "www.vbforums.com")
if you specifically want to use Internet Explorer. You don't have to qualify the execuatble because the Environment Path variable will sort that out. This would not be the case for all executables, of course, which is undoubtedly why RobDog888 used the full path. Alternatively, to use the default browser try:
VB Code:
Dim myProcess As Process = Process.Start("www.vbforums.com")
In fact, if you don't intend to use the Process object later, you don't even need to assign the result of Process.Start to a variable. Simply call it like a procedure:
VB Code:
Process.Start("www.vbforums.com")
Re: How to run InternetExplorer with long URL from VB
On my computer (Windows 2000 with MS Office 2000, and I use VB in Excel), 'Process' is not recognized as an known object. Any of the codes mentioned above containing 'Process" produced an error indicating the object was not defined.
Re: How to run InternetExplorer with long URL from VB
This is a VB.NET forum. If you are using VBA then post here and if you are using VB6 or earlier then post here.
Re: How to run InternetExplorer with long URL from VB
Looks like I dropped the ball on this one jmcilhinney. :blush:
"I use VB within MS office" so this is VBA.
Moved to VBA Forum.
Re: How to run InternetExplorer with long URL from VB
Quote:
Originally Posted by RobDog888
Looks like I dropped the ball on this one jmcilhinney. :blush:
"I use VB within MS office" so this is VBA.
Moved to VBA Forum.
You're forgiven (but not for the avatar :D). It was nanfei's first post so they can be forgiven too, but we all generally assume that a thread in this forum is VB.NET related. I read the thread title and it still didn't really register.
Re: How to run InternetExplorer with long URL from VB
See, you missed it too J. :p :lol:
Check out ShellExecute API for a possible solution since you can pass an argument of just the url.
If you think my current avatar is causing seizures then just wait for the next one. :lol:
Re: How to run InternetExplorer with long URL from VB
Not sure but maybe Webbrowser control??