Purpose: To print 50 hyperlinks internal webpages.
Hyperlinks are stored in Excel sheet (Sheet1)
Links are to be opened using IE 8 and giving focus on screen for user a prompt to print before going to next link
Problem: Currently it opens the 1st 5 pages and than gives error.
Error: Object required- 424 1
Object required- 424 1
Object required- 424 1
Object required- 424 1
Links:
There are 50 hyperlink stored in excel file starting from A2
sCol and iRow is to provide column and row for the hyperlink
Call PrntHyperLink("A", 2)
Code:
Hyperlinks are stored in Excel sheet (Sheet1)
Links are to be opened using IE 8 and giving focus on screen for user a prompt to print before going to next link
Problem: Currently it opens the 1st 5 pages and than gives error.
Error: Object required- 424 1
Object required- 424 1
Object required- 424 1
Object required- 424 1
Links:
There are 50 hyperlink stored in excel file starting from A2
sCol and iRow is to provide column and row for the hyperlink
Call PrntHyperLink("A", 2)
Code:
Code:
Public Sub PrntHyperLink(sCol As String, iRow As Integer)
On Error GoTo ErrPrint
'DIM oIE as Object
Dim oIE As Variant
Dim sPrintLink as String
Set oIE = New InternetExplorer
oIE.Visible = True
'To print HyperLink
For i = 1 To iRowEnd
iRow = iRow + 1
Range(sCol & iRow).Select
sPrintLink = Range(sCol & iRow).Value
oIE.Navigate sPrintLink
Do Until oIE.ReadyState = READYSTATE_COMPLETE
wscript.sleep 1000
Loop
oIE.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSE
' To Exit Printing
If iRow = 32 Then
MsgBox iRow, vbOKCancel
Range(sCol & iRow).Select
Exit For
End If
Next i
ErrPrint:
If iRow = iRowEnd Then
Exit Sub
ElseIf Err.Number = 424 Then
Debug.Print Err.Description & "-" & sPrintLink & " " & Err.Number, vbOKCancel
Resume Next
End If
End Sub