saggitarius
Gebruiker
- Lid geworden
- 8 jan 2011
- Berichten
- 34
Voor mijn werk ben ik het e.e.a. aan het "knutselen", maar het laatste stukje lukt niet
Ik heb de onderstaande VBA-code en wil op het eind het bestand afsluiten zonder dat er gevraagd wordt of ik het bestand wil opslaan (want dat is al gebeurd);
Weet iemand waar ik de fout maak?
Het begin gaat goed, alleen wordt het bestand niet gesloten
Sub opslaan()
Dim s_dir As String
s_dir = "-----:\----------\------------" & Range("C5").Value
If Dir(s_dir, vbDirectory) = "" Then MkDir s_dir
ActiveSheet.Copy
ActiveWorkbook.SaveAs s_dir & "" & Range("I2").Value & ".xls"
'stuurt mail na afronden
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Application.DisplayAlerts = True
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<font size=""3"" face=""Calibri"">" & _
"FYI,<br><br>" & _
"Er is een bestand aangemaakt of aangepast.<br><br>" & _
"Click op de link om het formulier te openen : " & _
"<A HREF=""file://" & ActiveWorkbook.FullName & _
""">Link naar formulier</A>"
On Error Resume Next
With OutMail
'email naar coordinator
.To = ActiveSheet.Range("X4")
.CC = ""
.BCC = ""
.Subject = ActiveSheet.Range("i2")
.HTMLBody = strbody
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Application.Quit
End Sub
Ik heb de onderstaande VBA-code en wil op het eind het bestand afsluiten zonder dat er gevraagd wordt of ik het bestand wil opslaan (want dat is al gebeurd);
Weet iemand waar ik de fout maak?
Het begin gaat goed, alleen wordt het bestand niet gesloten
Sub opslaan()
Dim s_dir As String
s_dir = "-----:\----------\------------" & Range("C5").Value
If Dir(s_dir, vbDirectory) = "" Then MkDir s_dir
ActiveSheet.Copy
ActiveWorkbook.SaveAs s_dir & "" & Range("I2").Value & ".xls"
'stuurt mail na afronden
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Application.DisplayAlerts = True
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<font size=""3"" face=""Calibri"">" & _
"FYI,<br><br>" & _
"Er is een bestand aangemaakt of aangepast.<br><br>" & _
"Click op de link om het formulier te openen : " & _
"<A HREF=""file://" & ActiveWorkbook.FullName & _
""">Link naar formulier</A>"
On Error Resume Next
With OutMail
'email naar coordinator
.To = ActiveSheet.Range("X4")
.CC = ""
.BCC = ""
.Subject = ActiveSheet.Range("i2")
.HTMLBody = strbody
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Application.Quit
End Sub