Imports System.IO Imports System.Runtime.InteropServices Imports Microsoft.Office.Interop Imports Microsoft.Office.Interop.Word Module PrinterBacklogDocMapper Public Sub addPrinterBacklogDoc(trayNummer As Integer, text As String, isSpecial As Boolean) Dim bestandsPath As String = Configs.printerBacklogPath Dim trayNummerTekst As String = trayNummer.ToString 'vullen met nullen For index = 1 To 4 - trayNummerTekst.Length trayNummerTekst = "0" & trayNummerTekst Next Dim bestandsnaam As String = "printer_backlog_" & trayNummerTekst If isSpecial Then bestandsnaam &= "_Special" End If Dim fullPath As String = Path.Combine(bestandsPath, bestandsnaam) Dim oWord As Object Dim oDoc As Object Try oWord = CreateObject("Word.Application") oDoc = New Word.Document Catch ex As Exception Throw New Exception("Print backlog kon niet worden aangemaakt, omdat Word niet is geïnstalleerd") End Try Try Dim oPara1 As Paragraph = oDoc.Content.Paragraphs.Add oPara1.Range.Font.Name = "Courier New" oPara1.Range.Font.Bold = False oPara1.Range.Font.Size = 13 oPara1.Range.Text = text oDoc.SaveAs2(fullPath) Dim save_changes As Object = False oDoc.Close(save_changes) oWord.Quit(save_changes) Catch ex As Exception Throw New Exception("Print backlog kon niet worden aangemaakt" & vbNewLine & ex.Message) End Try End Sub End Module