Results 1 to 17 of 17

Thread: [RESOLVED] Compatible method for InternetExplorerMedium

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    209

    Resolved [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:

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,076

    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?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    391

    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).

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,016

    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...

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    209

    Re: Compatible method for InternetExplorerMedium

    Quote Originally Posted by jmcilhinney View Post
    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?

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,016

    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")

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    209

    Re: Compatible method for InternetExplorerMedium

    Quote Originally Posted by -Franky- View Post
    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.

  8. #8
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,511

    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.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    209

    Re: Compatible method for InternetExplorerMedium

    Quote Originally Posted by .paul. View Post
    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.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    209

    Re: Compatible method for InternetExplorerMedium

    Quote Originally Posted by OptionBase1 View Post
    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.

  11. #11
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,817

    Re: Compatible method for InternetExplorerMedium

    Quote Originally Posted by FunkMonkey View Post
    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

  12. #12
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,817

    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

  13. #13
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    391

    Re: Compatible method for InternetExplorerMedium

    Quote Originally Posted by FunkMonkey View Post
    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

  14. #14
    Lively Member
    Join Date
    Jun 2017
    Posts
    92

    Re: Compatible method for InternetExplorerMedium

    Maybe look into Selenium?

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Mar 2025
    Posts
    209

    Re: Compatible method for InternetExplorerMedium

    Quote Originally Posted by Shaggy Hiker View Post
    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?

  16. #16
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,817

    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

  17. #17
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,076

    Re: Compatible method for InternetExplorerMedium

    Quote Originally Posted by FunkMonkey View Post
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width