Hello Gurus,

I am looking to tweak a code which converts a webpage to PDF and store it in a specific directory.

This solution is exactly what I am looking for but unfortunately this is not working in a "Share point environment".

Code:
Sub WebSMacro()

'set default printer to AdobePDF
Dim WSHNetwork As Object
Set WSHNetwork = CreateObject("WScript.Network")
WSHNetwork.SetDefaultPrinter "Adobe PDF"


'get pdfSave as Path from cell range
Dim sFolder As String
sFolder = Sheets("Sheet1").Range("A1") 'assumes folder save as path is in cell A1 of mySheets


Dim IE As Object
Dim Webloc As String
Dim FullWeb As String


Webloc = ActiveSheet.Range("B39").Value
FullWeb = "https://asharepointsiteurl.aspx" & Webloc
Set IE = CreateObject("InternetExplorer.Application")


With IE


    .Visible = True
    .Navigate FullWeb


    Do While .Busy
        Application.Wait DateAdd("s", 1, Now)
    Loop


    .ExecWB 6, 2 'OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
    Application.Wait DateAdd("s", 3, Now)
    Call PDFPrint(sFolder & Webloc & ".pdf")


    .Quit


End With


Set IE = Nothing


End Sub

I am getting the error in .ExecWB method(6,2 params should print the page without the dialog box ,which is working fine for all normal websites)

Can someone advice what is wrong here ? Is this something to do with the load time of the page?



Regards,