Dim excel_app As Excel.Application
Dim row As Integer
' Create the Excel application.
excel_app = CreateObject("Excel.Application")
' Uncomment this line to make Excel visible.
excel_app.Visible = False
' Create a new spreadsheet.
excel_app.Workbooks.Add()
' Insert data into Excel.
With excel_app
.Range("A1:H1").Merge()
.Range("A1").Select()
.ActiveCell.FormulaR1C1 = "BorduurCompany"
.ActiveCell.HorizontalAlignment = Constants.xlCenter
.Columns("A:A").ColumnWidth = 2
.Columns("B:B").ColumnWidth = 12
.Columns("C:C").ColumnWidth = 27
.Columns("D:D").ColumnWidth = 12
.Columns("E:E").ColumnWidth = 12
.Columns("F:F").ColumnWidth = 12
.Columns("G:G").columnwidth = 2
.Columns("H:H").columnwidth = 2
With .Selection.Font
.Name = "Century Gothic"
.Size = 40
.Color = RGB(238, 128, 28)
End With
.Range("A2:H2").Merge()
.Range("A2").Select()
.ActiveCell.FormulaR1C1 = "It's Me"
.ActiveCell.RowHeight = 90
.ActiveCell.VerticalAlignment = Constants.xlCenter
.ActiveCell.HorizontalAlignment = Constants.xlCenter
With .Selection.Font
.Name = "Another"
.Size = 100
.Color = RGB(238, 128, 28)
End With
.Range("A3:H3").Merge()
.Range("A3").Select()
.ActiveCell.FormulaR1C1 = "Merknaam van De Romerij BVBA"
.ActiveCell.HorizontalAlignment = Constants.xlRight
With .Selection.Font
.Name = "Century Gothic"
.Size = 10
.Color = RGB(238, 128, 28)
End With
.Range("A4:H4").Merge()
.Range("A4").Select()
.ActiveCell.RowHeight = 30
With .Selection.Borders(XlBordersIndex.xlEdgeBottom)
.LineStyle = XlLineStyle.xlContinuous
.Weight = XlBorderWeight.xlThick
.ColorIndex = 0
End With
.Range("B5").Select()
.ActiveCell.FormulaR1C1 = "Factuur"
.ActiveCell.HorizontalAlignment = Constants.xlLeft
With .Selection.Font
.Name = "Century Schoolbook"
.Size = 24
.Colorindex = 0
End With
.Range("B7").Select()
.ActiveCell.FormulaR1C1 = "Datum"
.ActiveCell.HorizontalAlignment = Constants.xlLeft
With .Selection.Font
.Name = "Century Schoolbook"
.Size = 11
.bold = True
.Colorindex = 0
End With
.Range("c7").Select()
.ActiveCell.FormulaR1C1 = "=vandaag()"
.ActiveCell.HorizontalAlignment = Constants.xlLeft
With .Selection.Font
.Name = "Century Schoolbook"
.Size = 11
.bold = False
.Colorindex = 0
End With
.Range("B8").Select()
.ActiveCell.FormulaR1C1 = "Factuurnr"
.ActiveCell.HorizontalAlignment = Constants.xlLeft
With .Selection.Font
.Name = "Century Schoolbook"
.Size = 11
.bold = True
.Colorindex = 0
End With
.Range("c8").Select()
.ActiveCell.FormulaR1C1 = DateAndTime.Today.Year() & DateAndTime.Today.Month()
.ActiveCell.HorizontalAlignment = Constants.xlLeft
With .Selection.Font
.Name = "Century Schoolbook"
.Size = 11
.bold = False
.Colorindex = 0
End With
.Range("B10").Select()
.ActiveCell.FormulaR1C1 = "BTWnr"
.ActiveCell.HorizontalAlignment = Constants.xlLeft
With .Selection.Font
.Name = "Century Schoolbook"
.Size = 11
.bold = True
.Colorindex = 0
End With
.Range("c10").Select()
.ActiveCell.FormulaR1C1 = btnBTWnummer.Text
.ActiveCell.HorizontalAlignment = Constants.xlLeft
With .Selection.Font
.Name = "Century Schoolbook"
.Size = 11
.bold = False
.Colorindex = 0
End With
.Range("A10:H10").Select()
With .Selection.Borders(XlBordersIndex.xlEdgeBottom)
.LineStyle = XlLineStyle.xlContinuous
.Weight = XlBorderWeight.xlThick
.ColorIndex = 0
End With
.Range("E6:F6").Merge()
.Range("E6").Select()
.ActiveCell.FormulaR1C1 = btnnaam.Text
.ActiveCell.HorizontalAlignment = Constants.xlLeft
With .Selection.Font
.Name = "Century Schoolbook"
.Size = 11
.bold = True
.Colorindex = 0
End With
.Range("E7:F7").Merge()
.Range("E7").Select()
.ActiveCell.FormulaR1C1 = btnadres.Text & " "
.ActiveCell.HorizontalAlignment = Constants.xlLeft
With .Selection.Font
.Name = "Century Schoolbook"
.Size = 11
.bold = True
.Colorindex = 0
End With
.Range("E8:F8").Merge()
.Range("E8").Select()
.ActiveCell.FormulaR1C1 = btnpostcode.Text & " " & btnplaats.Text
.ActiveCell.HorizontalAlignment = Constants.xlLeft
With .Selection.Font
.Name = "Century Schoolbook"
.Size = 11
.bold = True
.Colorindex = 0
End With
row = 4
.Range("A" & Format$(row)).Select()
.ActiveCell.Font.Color = RGB(238, 128, 28)
.ActiveCell.FormulaR1C1 = ""
' Save the results.
.ActiveWorkbook.SaveAs("testzoveel.xlsx")
End With
' Comment the rest of the lines to keep
' Excel running so you can see it.
' Close the workbook without saving.
excel_app.ActiveWorkbook.Close(False)
' Close Excel.
excel_app.Quit()
excel_app = Nothing
MsgBox("Ok")