+ Reply to Thread
Results 1 to 2 of 2

Error when trying to print from IE using VBA

  1. #1
    Registered User
    Join Date
    08-10-2012
    Location
    Adelaide
    MS-Off Ver
    Excel 2007
    Posts
    2

    Question Error when trying to print from IE using VBA

    I am trying to write a macro to open then print a PDF in Internet Explorer. Eventually I'd like to wait for the print command to be sent then close IE but I'm not there yet.

    I've hit a hurdle on sending the print command. Here's my code.

    Please Login or Register  to view this content.
    There error I get indicates;

    Run-time error '-2147221248 (80040100)':

    Method 'ExecWB' of object 'WebBrowser2' failed.


    Can someone please shed some light on where I've gone wrong? Many thanks

    Update 20181011A:
    I've made a slight update to the code changing the IE type from Object to InternetExplorerMedium and using a Do Loop to wait for IE's ready state as per below.

    Please Login or Register  to view this content.
    I'm no longer receiving the error but the print screen isn't triggered unless I put a breakpoint on the IE.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER line. This tells me that there is an issue around waiting for the page to load that I haven't picked up on.

    Any advice would be much appreciated.
    Attached Images Attached Images
    Last edited by anonunga; 10-10-2018 at 07:57 PM. Reason: Putting Code tags around code

  2. #2
    Registered User
    Join Date
    08-10-2012
    Location
    Adelaide
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Error when trying to print from IE using VBA

    Anyone?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Print Error ..
    By ks1102 in forum Excel General
    Replies: 0
    Last Post: 10-29-2014, 11:45 PM
  2. Print Macro errors on final print command. Run-time error '1004':
    By Steverizer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2013, 06:41 PM
  3. Print Macro / module error & Update / Clear Macro error
    By mal.b.graham in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-28-2012, 06:40 PM
  4. VBA to set print range, open box asking for print qty, print, then redefine print area
    By galvinpaddy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-11-2012, 06:43 PM
  5. Excel 2007 : Print error
    By nosfarratu in forum Excel General
    Replies: 1
    Last Post: 03-16-2012, 03:11 PM
  6. Excel 2010 print/print preview error for combo boxes
    By dlmcdan in forum Excel General
    Replies: 3
    Last Post: 03-23-2011, 12:32 PM
  7. Replies: 2
    Last Post: 11-04-2005, 09:40 PM

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