-
Notifications
You must be signed in to change notification settings - Fork 3
/
M_omExcel.def
60 lines (56 loc) · 2.65 KB
/
M_omExcel.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Compare Database
Option Explicit
Public xlApp As New Excel.Application
Public xlWB As Excel.Workbook
Public Sub LoadWB(filename As String)
Set xlWB = xlApp.Workbooks.Open(filename)
End Sub
Public Sub CloseWB(Optional saveChanges As Boolean = True, Optional filename As String = "")
If IsNullOrEmpty(filename) Then
xlWB.Close saveChanges
Else
xlWB.Close saveChanges, filename
End If
Set xlWB = Nothing
End Sub
Public Sub SetVisible(Optional visible As Boolean = True)
omExcelFunctions.SetVisible xlApp, visible
End Sub
Public Sub SelectColumn(columnIndex As Long)
omExcelFunctions.SelectColumn xlWB.ActiveSheet, columnIndex
End Sub
Public Sub SelectRow(rowIndex As Long)
omExcelFunctions.SelectRow xlWB.ActiveSheet, rowIndex
End Sub
Public Sub FormatColumn(columnIndex As Long, numberFormat As String)
omExcelFunctions.FormatColumn xlWB.ActiveSheet, columnIndex, numberFormat
End Sub
Public Sub FormatCells(Optional rowIndexStart As Long = 0, Optional columnIndexStart As Long = 0, Optional rowIndexEnd As Long = 0, Optional columnIndexEnd As Long = 0, Optional numberFormat As Variant = Null, Optional horizontalAlignment As Excel.Constants = xlLeft, Optional verticalAlignment As Excel.Constants = xlTop, Optional MergeCells As Boolean = False, Optional WrapText As Boolean = False)
omExcelFunctions.FormatCells xlWB.ActiveSheet, rowIndexStart, columnIndexStart, rowIndexEnd, columnIndexEnd, numberFormat, horizontalAlignment, verticalAlignment, MergeCells, WrapText
End Sub
Public Sub WriteCell(rowIndex As Long, columnIndex As Long, Value As Variant, Optional numberFormat As Variant = Null, Optional horizontalAlignment As Excel.Constants = xlLeft, Optional verticalAlignment As Excel.Constants = xlTop)
omExcelFunctions.WriteCell xlWB.ActiveSheet, rowIndex, columnIndex, Value
Me.FormatCells rowIndexStart:=rowIndex, columnIndexStart:=columnIndex, numberFormat:=numberFormat, horizontalAlignment:=horizontalAlignment, verticalAlignment:=verticalAlignment
End Sub
Public Sub InsertRows(rowIndex As Long, Optional numberOfRows As Long = 1)
Dim i As Long
For i = 1 To numberOfRows
omExcelFunctions.InsertRow xlWB.ActiveSheet, rowIndex
Next
End Sub
Public Sub AutoFit()
omExcelFunctions.AutoFitColumns xlWB.ActiveSheet
omExcelFunctions.AutoFitRows xlWB.ActiveSheet
End Sub
Public Sub SelectionUpdateBold(bold As Boolean)
UpdateFontOnSelection xlWB.ActiveSheet, bold
End Sub
Private Sub Class_Terminate()
Set xlWB = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub