I am trying to convert webpage to PDF and that Pdf need to be saved in one specific folder in desktop. I have pasted the below code which is working fine to make PDF, problem is ,,PDF is asking save location and popping up dialog box. So how to save PDF automatically in one folder.. please help.
Sub print_PDF()
Dim Explorer As Object
Dim folderPath As String
Dim eQuery As Long
Dim i As Integer
Dim FileAndLocation As Variant
Dim strPathLocation As String
Dim strFilename As String
Dim strPathFile, ChDir As String
strPathLocation = "C:\Desktop\Printed"
strFilename = "makingpdf"
strPathFile = strPathLocation & strFilename
SetDefaultPrinter "CutePDF Writer"
Set Explorer = CreateObject("InternetExplorer.Application")
Explorer.navigate "https://www.google.com/"
Set Explorer = New InternetExplorerMedium
sURL = "https://www.amazon.in/"
With Explorer
.navigate sURL
.Visible = True
End With
TryAgain:
Application.Wait Now + TimeSerial(0, 0, 6)
eQuery = Explorer.QueryStatusWB(6) 'get print command status
If eQuery And 2 Then
Explorer.ExecWB 6, 2, "", "" 'print dialogbox is coming..need to be automated for specific folder.......
Application.Wait Now + TimeSerial(0, 0, 6)
Else
GoTo TryAgain
End If
End Sub
Public Sub SetDefaultPrinter(ByVal printerName As String)
Dim oSH As WshNetwork
Set oSH = New WshNetwork
oSH.SetDefaultPrinter printerName
Set oSH = Nothing
End Sub