1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| Option Explicit
Dim URL As String
Declare Function ShellExecute& Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long)
Const SW_SHOWNORMAL = 1
Sub CicloDiStampa()
Dim ur As Integer, r As Integer
ur = Cells(65536, 1).End(xlUp).Row
For r = 1 To ur
If Cells(r, 1).Hyperlinks.Count <> 0 Then
URL = Cells(r, 1).Hyperlinks(1).Address
'stampa 'autre macro qui ne marche pas chez moi - désactivée pour l'instant
imprime (URL)
End If
Next
End Sub
Sub imprime(nomefile As String)
ShellExecute Application.hwnd, "open", nomefile, vbNullString, vbNullString, SW_SHOWNORMAL
ShellExecute Application.hwnd, "PRINT", nomefile, vbNullString, vbNullString, SW_SHOWNORMAL
End Sub
Sub stampa()
Dim oIExplorer As Object, wscript As Object
On Error Resume Next
'il valore 6 corrisponde alla stampa
Const OLECMDID_PRINT = 6
'Const OLECMDID_PRINT2 = 49
'con 2 eseguo il comando senza chiedere conferma
Const OLECMDEXECOPT_DONTPROMPTUSER = 2
Set oIExplorer = CreateObject("InternetExplorer.Application")
'carico l'indirizzo trovato
oIExplorer.Navigate URL
'imposta = 1 se vuoi aprire (o meglio vedere) la pagina web
oIExplorer.Visible = 0
'attendo che la pagina sia caricata
Do While oIExplorer.ReadyState <> 4
wscript.sleep 1000
Loop
oIExplorer.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
'oIExplorer.ExecWB OLECMDID_PRINT2, OLECMDEXECOPT_DONTPROMPTUSER
End Sub |
Partager