Moderatori: Anthony47, Flash30005
Sub Invioemail()
Dim OutApp As Object
Dim OutMail As Object
Dim EmailAddr As String
Dim Subj As String
Dim BodyText As String
EmailAddr = "email@email.com" '<<< inserire lo/gli indirizzi
Subj = "Saluti"
BodyText = "Ciao"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.to = EmailAddr
.CC = ""
.BCC = ""
.Subject = Subj
.body = BodyText
.send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Private Sub SendLotus()
Dim Maildb As Object
Dim UserName As String
Dim MailDbName As String
Dim MailDoc As Object
Dim AttachME As Object
Dim Session As Object
Dim EmbedObj As Object
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
Else
Maildb.OPENMAIL
End If
DestA1 = "Nome.Cognome@gestore.it, Nome2.Cognome2@gestore2.com" ' per più destinatari inserire "," + spazio + nuovo indirizzo (come da esempio)
DestA2 = "Nome.Cognome@gestore.it" 'oppure = ""
DestA3 = "Nome.Cognome@gestore.it" 'oppure = ""
DestinTO = DestA1
DestinCC = DestA2
DestinCN = DestA3
Dim Recipient, EnterSendTo As String
Recipient = DestinTO
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.SendTo = Recipient
MailDoc.CopyTo = DestinCC
MailDoc.BlindCopyTo = DestinCN
EnterSendTo = Recipient
MailDoc.Subject = "Scrivero Oggetto"
MailDoc.Body = "Corpo dell'email"
MailDoc.SAVEMESSAGEONSEND = True
attachment = "C:\Cartella\File.doc" 'allegato
If attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", attachment, "Attachment")
End If
MailDoc.SEND 0, Recipient
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub
Public valorecella As String
Public DestA1 As String
Public DestA2 As String
Sub SALVACONNOME()
'
' SALVACONNOME Macro
' Macro registrata il 03/12/2009 da Claudio
'
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim xlrange As Excel.Range
'Sub Importa()
'Dichiaro le variabili locali
Dim valorecella As String
Dim i As Integer
'Creo la nuova applicazione
Set xlApp = New Excel.Application
'Attraverso la nuova applicazione apro il Workbook
'assegnandolo alla variabile oggetto xlBook
Set xlBook = xlApp.Workbooks.Open("C:\.......\.........\........\......\ImportaExcel2.xls")
'Decido quale foglio utilizzare
Set xlSheet = xlBook.Worksheets("Foglio1")
valorecella = ActiveCell 'assegno alla variabile "valorecella" il contenuto della cella attiva del foglio1 di excel
ChangeFileOpenDirectory " C:\.......\.........\........\......\ARCHIVIOGENERALE"
ActiveDocument.SaveAs FileName:=valorecella, FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
'’’’’’’’’’’’’’’archiviare/inviare a cgherardi@tiscali.it ‘’’’’’’’’’’’’’
irisposta = MsgBox("YES per inviare a cgherardi@tiscali.it / NO per continuare senza inviare", vbYesNo)
If irisposta = vbYes Then
‘prima di inviare salvo il file col nome contenuto nella variabile “valorecella” nel percorso che segue
ChangeFileOpenDirectory " C:\.......\.........\........\......\CGHERARDI"
ActiveDocument.SaveAs FileName:=valorecella, FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
DestA1 = "cla.ghe@tiscali.it" ' per più destinatari inserire "," + spazio + nuovo indirizzo (come da esempio)
SendLotus 'mi sposto sull’applicazione SendLotus
End If
'’’’’’’’’’’’’’’archiviare/inviare a ppluto@tiscali.it ‘’’’’’’’’’’’’’
irisposta = MsgBox("YES per inviare a ppluto@tiscali.it / NO per continuare senza inviare", vbYesNo)
If irisposta = vbYes Then
‘prima di inviare salvo il file col nome contenuto nella variabile “valorecella” nel percorso che segue
ChangeFileOpenDirectory " C:\.......\.........\........\......\PPLUTO"
ActiveDocument.SaveAs FileName:=valorecella, FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
DestA2 = "ppluto@tiscali.it" ' per più destinatari inserire "," + spazio + nuovo indirizzo (come da esempio)
SendLotus 'mi sposto sull’applicazione SendLotus
End If
apredocbase ' apre un nuovo documento base
'ActiveWorkbook.Save
'Chiudo il Workbook e l'Applicazione
xlBook.Close (False)
xlApp.Quit
'Annullo le variabili per liberare le risorse
Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
Windows(valorecella).Activate 'attivo il documento appena salvato
ActiveDocument.Close ' e lo chiudo
End Sub
‘**************************************************
Sub SendLotus()
'Private Sub SendLotus()
Dim Maildb As Object
Dim UserName As String
Dim MailDbName As String
Dim MailDoc As Object
Dim AttachME As Object
Dim Session As Object
Dim EmbedObj As Object
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
Else
Maildb.OPENMAIL
End If
'DestA1 = "Nome.Cognome@gestore.it, Nome2.Cognome2@gestore2.com" ' per più destinatari inserire "," + spazio + nuovo indirizzo (come da esempio)
'DestA2 = "Nome.Cognome@gestore.it" 'oppure = ""
'DestA3 = "Nome.Cognome@gestore.it" 'oppure = ""
DestinTO = DestA1, DestA2
‘DestinCC = DestA2
‘DestinCN = DestA3
Dim Recipient, EnterSendTo As String
Recipient = DestinTO
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.SendTo = Recipient
MailDoc.CopyTo = DestinCC
MailDoc.BlindCopyTo = DestinCN
EnterSendTo = Recipient
MailDoc.Subject = "Trasmissione verbale"
MailDoc.Body = "Corpo dell'email"
MailDoc.SAVEMESSAGEONSEND = True
attachment = " C:\.......\.........\........\......\ valorecella" 'allegato
If attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", attachment, "Attachment")
End If
MailDoc.SEND 0, Recipient
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
End Sub
Sub DatiExcel()
Dim oApp As Object
percorso = "C:\Documenti\"
OutFile = "C:\Documenti\Prova.xls"
nomefile = "Prova.xls"
foglio = "Foglio1"
rif = "$A$4"
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
oApp.Workbooks.Open FileName:=(OutFile)
oApp.ActiveWindow.Visible = True
arg = "'" & percorso & "[" & nomefile & "]" & foglio & "'!" & oApp.Range(rif).Range("A1").Address(, , xlR1C1)
FileInvio = oApp.ExecuteExcel4Macro(arg)
oApp.Workbooks(nomefile).Close SaveChanges:=False
MsgBox FileInvio
End Sub
..........
valorecella = activedocument
attachment = " C:\.......\.........\........\......\" & valorecella" 'allegato
..........
Torna a Applicazioni Office Windows
Macro modifica date scelta periodo Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 11 |
Supporto per sviluppo macro VBA Ordinare per data Autore: Carletto Ribolla |
Forum: Applicazioni Office Windows Risposte: 3 |
Macro per aprire file salvato su sharepoint Onedrive Autore: marcopont |
Forum: Applicazioni Office Windows Risposte: 2 |
Visitano il forum: Nessuno e 15 ospiti