
Sub STAMPATUTTO()
Dim cs As Integer
' STAMPA I FOGLI COMPILATI
cs = Sheets("Form").Range("w42")
On Error Resume Next
Sheets(data).Select
Range("Area_stampa").PrintOut copies:=2
' stampa specifica TABELLA solo SE compilata
Range("tabracstampa").PrintOut copies:=cs
' stampa la distinta "racc" solo se compilata
Sheets("RACC").Activate
If Range("b11") <> blank Then
Range("Area_stampa").PrintOut copies:=2
End If
' stampa la distinta "ASS" solo se compilata
Sheets("ASS").Activate
If Range("b11") <> blank Then
Range("Area_stampa").PrintOut copies:=2
End If
Sheets("All. mail").Activate
MsgBox ("RICORDATI DI CREARE GLI ALLEGATI PER LA MAIL!!!")
End Sub |
Sub PDFEmail()
Dim MyFilePath As String
Dim MyFileName As String
Dim OutlookApp As Outlook.Application
Dim MItem As Outlook.MailItem '<-- Early binding
Dim EmailAddress As String
Dim EmailSubject As String
Dim Msg As String
Application.ScreenUpdating = False
'Activate the Transaction Form worksheet
Worksheets("Caravan1").Activate
'Specify email address, email subject, and a brief message
EmailAddress = Range("U6")
EmailSubject = Range("U7")
Msg = "Please see the attached file which contains your invoice."
MyFilePath = ThisWorkbook.Path & ""
MyFileName = ActiveSheet.Name
Range("J1:R51").ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
MyFilePath & MyFileName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= False
Set OutlookApp = New Outlook.Application
'Send out the email
Set MItem = OutlookApp.CreateItem(olMailItem)
With MItem
.To = EmailAddress
.Subject = EmailSubject
.Body = Msg
.Attachments.Add MyFilePath & MyFileName & ".PDF"
.Send
End With
Set OutlookApp = Nothing
MsgBox "Email has been sent."
Application.ScreenUpdating = True
End Sub |
Sub STAMPATUTTO()
Dim cs As Integer
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
'
' STAMPA I FOGLI COMPILATI
'
'
cs = Sheets("Form").Range("w42")
'
On Error Resume Next
Sheets(data).Select
Range("Area_stampa").PrintOut copies:=2
' stampa NEL NUMERO OCCORRENTE DI COPIE DELLA TABELLA SPECIFICA
Range("tabracstampa").PrintOut copies:=cs
'
' stampa e crea la distinta "racc" solo se compilata
'
data = Sheets("RACC").Range("c8")
If Foglio3.Range("b11") <> blank Then
Range("Area_stampa").PrintOut copies:=2
Foglio2.Range("$B$10:$F$61").AutoFilter Field:=1, Criteria1:="<>"
dracc = Application.GetSaveAsFilename("PERCORSOFILE
accomandate del " & data, filefilter:="PDF (*.pdf), *.pdf", Title:="Salva PDF")
If dracc = Falso Then Exit Sub
Foglio2.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=dracc, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End If
' stampa e crea la distinta "ASS" solo se compilata
'
If Foglio9.Range("b11") <> blank Then
Range("Area_stampa").PrintOut copies:=2
Foglio10.Range("$B$10:$F$61").AutoFilter Field:=1, Criteria1:="<>"
dass = Application.GetSaveAsFilename("PERCORSOFILEassicurate del " & data, filefilter:="PDF (*.pdf), *.pdf", Title:="Salva PDF")
If dass = Falso Then Exit Sub
Foglio10.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=dass, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End If
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
' manda la mail con gli allegati se creati
With OutMail
.To = "address@dominio"
.CC = ""
.BCC = ""
.Subject = "spedizione odierna"
.Body = "Buongiorno," & Chr(13) & "blablabla" & Chr(13) & Chr(13) & "Distinti saluti." & Chr(13) & Chr(13) & "firma" & Chr(13)
.Attachments.Add (dracc)
.Attachments.Add (dass)
' .Display
' abilitando display e disabilitando send si può vedere cosa si sta mandando
viceversa si puo verifica in posta inviata da outlook
.Send
End With
Sheets(data).Activate
msgbox ("sei stato bravo...." & vbLf & _
"ora ricordati di SALVARE!!!")
End Sub |
Public Function fSendThunderbird(strTo As String, strSubject As String, strBody As String)
strCommand = "C:Program FilesMozilla Thunderbird hunderbird"
strCommand = strCommand & " -compose " & Chr$(34) & "mailto:" & strTo & "?"
strCommand = strCommand & "subject=" & Chr$(34) & strSubject & Chr$(34) & "&"
strCommand = strCommand & "body=" & Chr$(34) & strBody & Chr$(34)
Call Shell(strCommand, vbNormalFocus)
End Function |
