+ Reply to Thread
Results 1 to 7 of 7

Macro to print web page and close browser

  1. #1
    Registered User
    Join Date
    05-06-2004
    Posts
    60

    Macro to print web page and close browser

    Hello,

    I would like to create a macro to open IE, navigate to a web page, print the page (3 copies) and close the browser. The folling code will navigate to the web page, but I can't figure out how to print the page. I believe I can close the browser with IEapp.quit Any help would be greatly appreciated.

    Thanks

    Oreg


    Sub getgeolink()

    Dim IeApp As InternetExplorer
    Dim sURL As String
    Dim IeDoc As Object
    Dim i As Long

    Set IeApp = New InternetExplorer

    IeApp.Visible = True

    sURL = "http://www.excelforum.com"

    IeApp.navigate sURL

    Do
    Loop Until IeApp.ReadyState = READYSTATE_COMPLETE

    Set IeApp = Nothing

    End Sub

  2. #2
    Tim Williams
    Guest

    Re: Macro to print web page and close browser

    IeApp.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER

    Tim

    "Oreg" <Oreg.25tqln_1144295702.3666@excelforum-nospam.com> wrote in message
    news:Oreg.25tqln_1144295702.3666@excelforum-nospam.com...
    >
    > Hello,
    >
    > I would like to create a macro to open IE, navigate to a web page,
    > print the page (3 copies) and close the browser. The folling code will
    > navigate to the web page, but I can't figure out how to print the page.
    > I believe I can close the browser with IEapp.quit Any help would be
    > greatly appreciated.
    >
    > Thanks
    >
    > Oreg
    >
    >
    > Sub getgeolink()
    >
    > Dim IeApp As InternetExplorer
    > Dim sURL As String
    > Dim IeDoc As Object
    > Dim i As Long
    >
    > Set IeApp = New InternetExplorer
    >
    > IeApp.Visible = True
    >
    > sURL = "http://www.excelforum.com"
    >
    > IeApp.navigate sURL
    >
    > Do
    > Loop Until IeApp.ReadyState = READYSTATE_COMPLETE
    >
    > Set IeApp = Nothing
    >
    > End Sub
    >
    >
    > --
    > Oreg
    > ------------------------------------------------------------------------
    > Oreg's Profile:
    > http://www.excelforum.com/member.php...fo&userid=9195
    > View this thread: http://www.excelforum.com/showthread...hreadid=530357
    >




  3. #3
    Registered User
    Join Date
    05-06-2004
    Posts
    60

    RE: Macro to print web page and close browser

    Tim,

    Thanks for the help. I've encountered a script error and haven't been successful in figuring out what's wrong. here's the error:

    A run time error has occurred. Line 227 Error: 'dialogArguments._IE_PrintType' is null or not an object.

    My current OS is 2000. I've tried many suggestions via the web such as adding SYSTEM and INTERACTIVE to my default security permissions in DCOMCNFG.EXE and unchecking 3rd party browser extensions in internet options tab. Do you know where I'm going wrong?

    Thanks,

    Oreg

  4. #4
    Registered User
    Join Date
    05-06-2004
    Posts
    60

    Macro to print web page and close browser

    Hello,

    Could anyone point me in the right direction with the following error:

    Line: 228
    Char: 1
    Error: 'dialogArguments_IE_PrintType' is null or not an object
    Code: 0
    URL: res://C:\WINNT\system32\shdoclc.dll/preview.dlg

    I receive this error when using Tim's code in my macro to print a webpage (see below)

    IeApp.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER


    Here's what I've tried so far:

    1. Added SYSTEM and INTERACTIVE to my default security permissions in DCOMCNFG.EXE
    2. Added a references : sendcmsg.dll, to my form
    3. Reinstalled Windows 5.6 Scripting Engine
    4. Unchecked 3rd party browser extensions in advanced tab of internet options
    5. Enabled all scripting / active X & java controls in security tab of internet options
    6. Disabled smooth scrolling

    Thank you

    Oreg

  5. #5
    Tim Williams
    Guest

    Re: Macro to print web page and close browser

    > Error: 'dialogArguments_IE_PrintType' is null or not an object

    I was using XP for my testing, so there may be some differences there.


    Try:
    http://support.microsoft.com/default...;EN-US;q293176
    http://support.microsoft.com/default...;EN-US;Q303360

    Tim


  6. #6
    Registered User
    Join Date
    05-06-2004
    Posts
    60
    Hi Tim,

    Thanks again for responding. My default printer is a network printer where I work. I do not have permissions to change spool settings so that could be the trouble. I will try to print to another printer and see if the trouble follows.
    Are there any other options for printing like a sendkeys method once the webpage has completely loaded?

    Oreg

  7. #7
    Registered User
    Join Date
    05-06-2004
    Posts
    60
    Tim,

    I found the trouble ! IeApp.quit was not allowing enough time to print the webpage. I was able to fix by using sleep to slow down macro. Thanks again for your help.

    Oreg

+ 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