+ Reply to Thread
Results 1 to 11 of 11

VBA with Internet Explorer

  1. #1
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    VBA with Internet Explorer

    Hi,
    I have been trolling this forum for a while and have mostly been able to search for answers. I am stuck now. I am a novice VBA user. I am trying to use VBA to control an IE website, which it works all the way to the end but the end result page which I would like to save as a .mht in a specified path without the user clicking save as. Anybody run into this?

    Thanks,
    Mike

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,086

    Re: VBA with Internet Explorer

    Are you going to give any clues as to what the VBA code looks like? :-)

    A sample workbook would be helpful.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with Internet Explorer

    Please Login or Register  to view this content.
    Then the code I was trying to get to work is:
    Please Login or Register  to view this content.
    Thanks,
    Mike

  4. #4
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with Internet Explorer

    anybody? This is the last step to my project lol

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA with Internet Explorer

    Hello mike20255,

    It appears you are logging on to a website. What are you doing with the Input element?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with Internet Explorer

    It clicks a button and then produces a page that all I want to do with that page is go file save as and have a constant path that needs no input from the user.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA with Internet Explorer

    Hello Mike,

    As I understand this, you log into the website and open another page by clicking a button. Afterwords, you want to save this page to a file on your hard drive?

  8. #8
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with Internet Explorer

    Exactly. I want to save the page as a .mht
    You can go file save as and select the path but I would like this to be automated.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA with Internet Explorer

    Hello mike,

    Try this method.
    Please Login or Register  to view this content.

    These constants will not work if you have not set a reference to the Microsoft Internet Controls library. The constants values are 4, and 2 respectively. If this doesn't work, I have an API routine to download a web page to a file.

  10. #10
    Registered User
    Join Date
    10-28-2010
    Location
    Ottawa, Ontario
    MS-Off Ver
    Excel 2003
    Posts
    17

    Re: VBA with Internet Explorer

    Thanks. Unfortunately it doesn't work it is still prompting the save as dialog box and gives me an error:
    Method ‘ExecWB’ of object ‘IWebBrowser2’ failed

    I do have the Microsoft Internet Controls Reference selected.

    Thanks,
    Mike

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA with Internet Explorer

    Hello Mike,

    Okay, time for plan "B". This macro will download a whole page to file on your hard drive. The macro only needs the address of the web page, the new file path, and new file name. Download this code into a separate VBA module.

    I didn't see any variables that you had declared for the file path and name in your code.You will need to add the file path and name to your macro. Presently, I have added the variables FilePath and FileName to your macro. You will need to assign values to them.
    Please Login or Register  to view this content.

    Here is the updated version of your macro code.
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1