none
VS2017 VB.Net will not accept MSHTML references in code

    Question

  • I have been looking at the code examples in http://www.vb-tips.com/MSHTML.aspx to see if they would resolve my problem getting my VB.Net project to open a remote website, put an two addresses into two input text boxes on that website, and then activate the form's submit button. 

    The MSHTML example looks promising but the lines of code (see below) involving MSHTML are not recognized as valid VB.Net code, and the all  files listing using Solution Explorer does not show MSHTML - preventing me from setting the Embeded Inerop type to false.  I do NOT finding anything in the References that looks like it applies to MSHTL. 

    Can you tell me how to overcome this?

    Bob Goodwin

    Dim Doc As mshtml.IHTMLDocument2
    
    'The line bellow will give an error in Frameworks higher than 2.0
    'To overcome that you have to show all files using Solution Explorer 
    'And set in the mshtml properties Embeded Interop type to false.
    
     Doc = New mshtml.HTMLDocumentClass
    


    Bob Goodwin

    Wednesday, April 5, 2017 5:55 PM

Answers

  • Hi BobGn,

    Based on your description, you can right-click Reference ---choose Add Reference---Browse---click Browse.. button--- choose C:\Windows\assembly\GAC\Microsoft.mshtml field to add mshtml.dll, then Imports mshtml in your project. Finally you can find Microsoft.mshtml in the reference, and left-click to modify its properties.

    Best Regards,

    Cherry Bu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by BobGn Thursday, April 6, 2017 10:50 AM
    Thursday, April 6, 2017 9:05 AM
    Moderator
  • Bob,

    You must use the browse part on the page you show to search for MSHTML 

    There are few .Net libraries in this category which start with Microsoft. 

    Pay also attention to this text on this page. If I could run it, then you can run it. (You can see I did do it now because I even had a little textbox, normally I set direct a more line textbox)

    'Set a reference in full versions of Visual Studio to MSHTML in Express you have 

    'to download the SDK for the framework version you use.



    Success
    Cor



    • Edited by Cor LigthertMVP Thursday, April 6, 2017 6:37 AM
    • Marked as answer by BobGn Thursday, April 6, 2017 10:50 AM
    Thursday, April 6, 2017 6:32 AM

All replies

  • Bob,

    I was curious if it was still running on Visual Studio 2017, it does

    But probably you've the wrong MSHTML Dll, there are mostly more, but that are not the classes you need. 

    I took this one. 


    Success
    Cor

    Wednesday, April 5, 2017 9:23 PM
  • Cor,
         Thanks for your response.  I hate to be obtuse, but such is the state of my ignorance.  How do I download/activate the MSHTML.dll that you show above?  I assume that it is via the 'Add a Reference' option, but when I search the Add a Reference list, I cannot find anything that is related to MSHTML, or even suggestive of a relation to MSHTM.  Which reference should be checked?  If it is not acquired via the 'Add a Reference' then how/where does it come from?  The current state of my References is shown in the 3 pictures below.

    Looking at this list of references, I am struck how few references are actually checked and by the 3 unchecked Visual Basic references, near the top of the list, and the 15 web related references closer to the bottom.  Is my list of activated reference too few?  Have I somehow failed to activate a proper set of references for use in a forms based project that needs to interface with a website via the VB.NET language?

    Bob Goodwin



        

    Bob Goodwin

    Thursday, April 6, 2017 1:49 AM
  • Bob,

    You must use the browse part on the page you show to search for MSHTML 

    There are few .Net libraries in this category which start with Microsoft. 

    Pay also attention to this text on this page. If I could run it, then you can run it. (You can see I did do it now because I even had a little textbox, normally I set direct a more line textbox)

    'Set a reference in full versions of Visual Studio to MSHTML in Express you have 

    'to download the SDK for the framework version you use.



    Success
    Cor



    • Edited by Cor LigthertMVP Thursday, April 6, 2017 6:37 AM
    • Marked as answer by BobGn Thursday, April 6, 2017 10:50 AM
    Thursday, April 6, 2017 6:32 AM
  • Hi BobGn,

    Based on your description, you can right-click Reference ---choose Add Reference---Browse---click Browse.. button--- choose C:\Windows\assembly\GAC\Microsoft.mshtml field to add mshtml.dll, then Imports mshtml in your project. Finally you can find Microsoft.mshtml in the reference, and left-click to modify its properties.

    Best Regards,

    Cherry Bu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by BobGn Thursday, April 6, 2017 10:50 AM
    Thursday, April 6, 2017 9:05 AM
    Moderator