Attribute VB_Name = "mod1Oefeningen" Option Explicit Sub Oefening1() Dim objWord As Object Dim objDocument As Object Set objWord = CreateObject("Word.Application") Set objDocument = objWord.Documents.Add objWord.Visible = True objDocument.Content.InsertAfter Text:="Hello World" Set objDocument = Nothing Set objWord = Nothing End Sub Sub Oefening2() Dim objOutlook As Object Dim objMail As Object Set objOutlook = CreateObject("Outlook.Application") Set objMail = objOutlook.CreateItem(0) With objMail .To = "info@pascalterheege.nl" .CC = "" .Subject = "Testbericht" .Body = "Hello World" '.Attachment.Add "" .Display '.Send End With Set objMail = Nothing Set objOutlook = Nothing End Sub Sub Oefening3() Dim objCN As Object Dim objRS As Object Dim strBron As String Set objCN = CreateObject("ADODB.Connection") Set objRS = CreateObject("ADODB.RecordSet") strBron = ThisWorkbook.Path & "\Bronnen\Databank.accdb" With objCN .ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " & strBron .Open End With With objRS .Open "SELECT * FROM Contactpersonen", objCN .MoveFirst Do While Not objRS.EOF Debug.Print .Fields("Voornaam").Value .MoveNext Loop End With Set objRS = Nothing Set objCN = Nothing End Sub Dim objOutlook As Object Dim objMail As Object Set objOutlook = CreateObject("Outlook.Application") Set objMail = objOutlook.CreateItem(0) With objMail .To = "info@pascalterheege.nl" .CC = "" .Subject = "Testbericht" .Body = "Hello World" .Display End With Set objMail = Nothing Set objOutlook = Nothing
Download hier het bestand.