-
Mar 14th, 2025, 04:59 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Compatible method for InternetExplorerMedium
I'm porting code from VBA to VB. VB does not seem to recognize InternetExplorerMedium. What is the correct code to use in place of InternetExplorerMedium? Below is my browser code.
Code:
Public Function LoadBrowser() As Boolean
Dim bStatus As Boolean
'Handle any erros we may have cleanly
On Error GoTo Err_Hndlr
' AbortRun = False
If (bDoDebug) Then
Debug.Print ("clsIIE [LoadBrowser Enter]")
End If
Set m_oBrowser = New InternetExplorerMedium
' Set m_oBrowser = New InternetExplorer
UpdateProgressBar
Sleep (200)
'Assume success
bStatus = False
'Initially keep the Browser hidden
m_oBrowser.Visible = False
DoEvents
'Navigate to URL
m_oBrowser.navigate cURL_IE
BrowserWait
UpdateProgressBar
Sleep (100) 'disabled
'Now let's display the window
m_oBrowser.Visible = True
Clean_Exit:
If (bDoDebug) Then
Debug.Print ("clsIIE [LoadBrowser Exit]")
End If
LoadBrowser = bStatus
Exit Function
Err_Hndlr:
-
Mar 14th, 2025, 10:47 PM
#2
Re: Compatible method for InternetExplorerMedium
When you ask a question like this with so little information, it requires someone to have knowledge of VBA in order to answer, which limits your pool of possible respondents. I've never used VBA, so I have no idea what InternetExplorerMedium is or does. If you provide some explanation as to what you're trying to achieve then I and others who haven't used VBA may be able to explain the best way to do that in VB.NET. Are you trying to automate an IE window with that code?
-
Mar 15th, 2025, 02:14 AM
#3
Re: Compatible method for InternetExplorerMedium
In VBA, FunkMonkey will certainly use a reference to the MSHTML or SHDocVw (CLSID_InternetExplorerMedium) to create or use a WebBrowser (InternetExplorer).
-
Mar 15th, 2025, 05:40 AM
#4
Re: Compatible method for InternetExplorerMedium
In VB.Net you can use a WebBrowser control. It's not the same as automating IE as you seem to be trying to do...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 15th, 2025, 05:24 PM
#5
Thread Starter
Addicted Member
Re: Compatible method for InternetExplorerMedium
 Originally Posted by jmcilhinney
When you ask a question like this with so little information, it requires someone to have knowledge of VBA in order to answer, which limits your pool of possible respondents. I've never used VBA, so I have no idea what InternetExplorerMedium is or does. If you provide some explanation as to what you're trying to achieve then I and others who haven't used VBA may be able to explain the best way to do that in VB.NET. Are you trying to automate an IE window with that code?
Understood. So the code creates/opens and makes the webpage visible. I'm looking for similar code that will create the window that "Set m_oBrowser = New InternetExplorerMedium" does. This is the function which generates the new browser window. Any other suggestions?
-
Mar 15th, 2025, 05:33 PM
#6
Re: Compatible method for InternetExplorerMedium
You just want to show a webpage in a browser? That's easy. Not so easy to interact with it though...
Code:
Process.Start("https://www.vbforums.com/forumdisplay.php?25-Visual-Basic-NET")
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 15th, 2025, 05:42 PM
#7
Thread Starter
Addicted Member
Re: Compatible method for InternetExplorerMedium
 Originally Posted by -Franky-
In VBA, FunkMonkey will certainly use a reference to the MSHTML or SHDocVw (CLSID_InternetExplorerMedium) to create or use a WebBrowser (InternetExplorer).
Thanks. Actually that's not ture. I create the window and operate it from the Object returned as shown in the code. Been doing this for around 5 years now with no issues. I'll try this with the VB, maybe that's the issue.
-
Mar 15th, 2025, 05:53 PM
#8
Re: Compatible method for InternetExplorerMedium
Out of curiosity, what is your reason for leaving VBA? Pretty much every thread of your has some level of mention of how much easier it is/was to do what you wanted to to in VBA.
-
Mar 15th, 2025, 05:56 PM
#9
Thread Starter
Addicted Member
Re: Compatible method for InternetExplorerMedium
 Originally Posted by .paul.
You just want to show a webpage in a browser? That's easy. Not so easy to interact with it though...
Code:
Process.Start("https://www.vbforums.com/forumdisplay.php?25-Visual-Basic-NET")
That's not a true statement either. I use Getelement and other web browser calls to control our work Webpage. So the way that is written is not an issue. Been manipulating the browser for around 5 years now. Porting it over to VB as IE is going to go away sometime and I want to be prepared for that.
-
Mar 15th, 2025, 06:01 PM
#10
Thread Starter
Addicted Member
Re: Compatible method for InternetExplorerMedium
 Originally Posted by OptionBase1
Out of curiosity, what is your reason for leaving VBA? Pretty much every thread of your has some level of mention of how much easier it is/was to do what you wanted to to in VBA.
Because IE is not supported and our company and is going to do away with it sometime in the future. I want it ported so we will at least have the program to continue to be able to work with it in Edge. It processes records and losing the program all together will mean more work when it is now being performed via automation. Processing over 7,000 records in one group and another 7,000 in a different group.
It's a must do for the work situation. And since work will eventually not allow IE to launch this must be done sooner or later. I prefer sooner so I can come up to speed with VB and eventually overcome the struggle it is causing now.
-
Mar 15th, 2025, 07:13 PM
#11
Re: Compatible method for InternetExplorerMedium
 Originally Posted by FunkMonkey
That's not a true statement either. I use Getelement and other web browser calls to control our work Webpage. So the way that is written is not an issue. Been manipulating the browser for around 5 years now. Porting it over to VB as IE is going to go away sometime and I want to be prepared for that.
The statement is true. What .Paul. showed was a way to simply display a web page in .NET. If you use that method, though, you will find it very hard to interact with it, as he said. That method is essentially launching a browser that your program knows little about and has little access to, which makes it quite hard to use that method to interact with the page.
My usual boring signature: Nothing
 
-
Mar 15th, 2025, 07:18 PM
#12
Re: Compatible method for InternetExplorerMedium
I typically tell people not to bother trying to automate a web site, but this might be an exception to that. My reasoning is that messing with a website is awkward and error prone, but largely because web masters can't seem to resist rebuilding their sites using different techniques. You make it sound like this is your own site (or that of your company), in which case you'd know very well if the site was going to change. That would be quite a different matter. It would invalidate the reason why I suggest people not do this, but it would create a whole new issue, as manipulating your own website is a pretty odd thing to do, since you could (usually) do the same work more easily using a webservice, or some such.
After reading over what you posted, I'm not clear on who owns what. You certainly have control over the program, but what about the site?
My usual boring signature: Nothing
 
-
Mar 16th, 2025, 02:48 AM
#13
Re: Compatible method for InternetExplorerMedium
 Originally Posted by FunkMonkey
Thanks. Actually that's not ture. I create the window and operate it from the Object returned as shown in the code. Been doing this for around 5 years now with no issues. I'll try this with the VB, maybe that's the issue.
I'm not familiar with VBA, and it's possible that Set Object = New InternetExplorerMedium works just fine in VBA. In the end, an InternetExplorerMedium object is created in the background, regardless of the method used (reference to..., CoCreateInstance, CreateObject, etc.) -> https://learn.microsoft.com/en-us/pr...vs.85)#remarks
-
Mar 16th, 2025, 01:39 PM
#14
Lively Member
Re: Compatible method for InternetExplorerMedium
Maybe look into Selenium?
-
Mar 17th, 2025, 11:40 AM
#15
Thread Starter
Addicted Member
Re: Compatible method for InternetExplorerMedium
 Originally Posted by Shaggy Hiker
I typically tell people not to bother trying to automate a web site, but this might be an exception to that. My reasoning is that messing with a website is awkward and error prone, but largely because web masters can't seem to resist rebuilding their sites using different techniques. You make it sound like this is your own site (or that of your company), in which case you'd know very well if the site was going to change. That would be quite a different matter. It would invalidate the reason why I suggest people not do this, but it would create a whole new issue, as manipulating your own website is a pretty odd thing to do, since you could (usually) do the same work more easily using a webservice, or some such.
After reading over what you posted, I'm not clear on who owns what. You certainly have control over the program, but what about the site?
The Website is works internal operation website. It processes records for the company and usually requies a person to interface it. However, because of work loads I wrote a VBA, now converting to VB, to automate certain types of records that are ready for closing. There are over 7,000 in one group and another 7,000 in another. Rather than having a person push about 12 different buttons to close the records we are automating this, due to manpower issues.
VBA works fine, but rumous are that the company is going to block IE soon, so I'm getting ahead of this by generating a VB version. Hope this clears things up?
-
Mar 17th, 2025, 03:31 PM
#16
Re: Compatible method for InternetExplorerMedium
If it is internal, then how about using something like a webservice instead? A webservice would consist of a series of functions that you can call from...well, from pretty nearly anywhere. They look like any other URL, they are just functions and act like functions. There's no visible user interface. This tends to be easier for a program to work with.
If you're interested in that, you might look into WebAPI.
My usual boring signature: Nothing
 
-
Mar 17th, 2025, 10:01 PM
#17
Re: Compatible method for InternetExplorerMedium
 Originally Posted by FunkMonkey
VBA works fine, but rumous are that the company is going to block IE soon, so I'm getting ahead of this by generating a VB version. Hope this clears things up?
If the company is going to stop supporting IE, how does creating a VB.NET tool to automate IE the way your VBA tool did help you? It sounds like you should be writing a VB.NET tool to interface with a supported browser, probably Edge. Also, if you're going to do that, you should be using a WebView2 control in your own app, rather than trying to automate an external window.
That said, Shaggy is right that, if at all possible, you should be developing a web service rather than trying to automate a browser. A web service is basically a web site with no UI, so it would be installed on the same web server as the web site and have the same access to the database. You can then simply invoke an API endpoint from an application or tool and then the code running on the web server can do all the work required without pressing any buttons. Of course, this assumes that you have permission to install something on the web server, which may not be the case. It's worth trying to convince the right people to let you though, because this would be a far more robust solution than anything that seeks to automate a web site, regardless of the language or browser.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|