none
How to select a specific folder to print an html to using VBA? RRS feed

  • Question

  • 'How do i send this to a specified folder??

    OptionExplicitConst OLECMDID_PRINT = 6 Const OLECMDEXECOPT_DONTPROMPTUSER = 1 Const PRINT_WAITFORCOMPLETION = 2 Sub Sample() Dim objIE Set objIE = CreateObject("InternetExplorer.Application") objIE.Navigate "http://www.Google.com/" objIE.Visible = 1 DoWhile objIE.ReadyState <> 4 DoEvents Loop objIE.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER EndSub


    Thursday, December 21, 2017 2:05 AM

All replies

  • Hi DJ Anderson,

    Your code seems to print a web page to a printer.
    What do you want to save in a specific folder?  Is it a picture?
    Please provide more details about what you want to do.

    This code works fine, if you print a web page to a printer.
         
    Option Explicit
    
        Const OLECMDID_PRINT = 6
        Const OLECMDEXECOPT_DONTPROMPTUSER = 1
        Const PRINT_WAITFORCOMPLETION = 2
    ' ---------------------------------------------
    Private Sub btn_PrintWebPage_Click()
        Dim objIE As Object
        Set objIE = CreateObject("InternetExplorer.Application")
        ' ---
        ' objIE.Navigate "http://www.Google.com/"
        Dim URL As String: URL = Range("B1").Value
        objIE.Navigate URL
        objIE.Visible = 1
        ' ---
        Do While objIE.ReadyState <> 4
            DoEvents
        Loop
        ' ---
        objIE.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
    End Sub

    Regards,

    Ashidacchi

    Thursday, December 21, 2017 3:49 AM
  • Hello, 

    Our forum is for development issues when using Excel Object Model. I would move this thread into VBA forum as this issue about automating IE is out of scope. Sorry for any inconvenience.

    Regards,

    Celeste


    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.

    Friday, December 22, 2017 3:01 AM
    Moderator