85829efd1d
WARNING! Do not assume the Excel file in this repo matches the VBA in the repo. The decision was made to use Teams for managing changes to the Excel tamplate because Git is ill-suited for binary files. The Excel file will be updated from time to time, but only when something major happens with the application as a whole. 1. Use the sheets' codenames to refer to them in code. This prevents breakage if the user changes the sheet name while working with the workbook. 2. Give the pivot tables proper, if not descriptive, names. 3. Simplify the code that detects a double-click in the pivot table. 4. Remove Windows_API as it was not being used. 5. Pare down TheBigOne to just the essential functions in Utils. 6. Refer to the data sources for the userforms' listboxes by using the worksheet.ListObjects collection.
129 lines
2.8 KiB
Plaintext
129 lines
2.8 KiB
Plaintext
VERSION 5.00
|
|
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} changes
|
|
Caption = "History"
|
|
ClientHeight = 7785
|
|
ClientLeft = 120
|
|
ClientTop = 465
|
|
ClientWidth = 16710
|
|
OleObjectBlob = "changes.frx":0000
|
|
StartUpPosition = 1 'CenterOwner
|
|
End
|
|
Attribute VB_Name = "changes"
|
|
Attribute VB_GlobalNameSpace = False
|
|
Attribute VB_Creatable = False
|
|
Attribute VB_PredeclaredId = True
|
|
Attribute VB_Exposed = False
|
|
Private x As Variant
|
|
|
|
Private Sub cbCancel_Click()
|
|
|
|
Me.Hide
|
|
|
|
End Sub
|
|
|
|
Private Sub cbUndo_Click()
|
|
|
|
|
|
Call Me.delete_selected
|
|
|
|
End Sub
|
|
|
|
Private Sub lbHist_Change()
|
|
|
|
Dim i As Integer
|
|
|
|
For i = 0 To Me.lbHist.ListCount - 1
|
|
If Me.lbHist.Selected(i) Then
|
|
Me.tbPrint.value = x(i, 7)
|
|
Exit Sub
|
|
End If
|
|
Next i
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub lbHist_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
|
|
|
|
Select Case KeyCode
|
|
Case 46
|
|
Call Me.delete_selected
|
|
Case 27
|
|
Call Me.Hide
|
|
End Select
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
Private Sub UserForm_Activate()
|
|
|
|
Dim fail As Boolean
|
|
|
|
'x = handler.list_changes("{""user"":""" & Application.UserName & """}", fail)
|
|
x = handler.list_changes("{""scenario"":{""quota_rep_descr"":""" & shData.Cells(2, 5) & """}}", fail)
|
|
If fail Then
|
|
Me.Hide
|
|
Exit Sub
|
|
End If
|
|
Me.lbHist.list = x
|
|
|
|
lbHEAD.ColumnCount = lbHist.ColumnCount
|
|
lbHEAD.ColumnWidths = lbHist.ColumnWidths
|
|
|
|
' add header elements
|
|
lbHEAD.clear
|
|
lbHEAD.AddItem
|
|
lbHEAD.list(0, 0) = "Modifier"
|
|
lbHEAD.list(0, 1) = "Owner"
|
|
lbHEAD.list(0, 2) = "When"
|
|
lbHEAD.list(0, 3) = "Tag"
|
|
lbHEAD.list(0, 4) = "Comment"
|
|
lbHEAD.list(0, 5) = "Sales"
|
|
lbHEAD.list(0, 6) = "id"
|
|
Call Utils.frmListBoxHeader(Me.lbHEAD, Me.lbHist, "Modifier", "Owner", "When", "Tag", "Comment", "Sales", "id")
|
|
|
|
|
|
' make it pretty
|
|
'body.ZOrder (1)
|
|
'lbHEAD.ZOrder (0)
|
|
'lbHEAD.SpecialEffect = fmSpecialEffectFlat
|
|
'lbHEAD.BackColor = RGB(200, 200, 200)
|
|
'lbHEAD.Height = 10
|
|
|
|
' align header to body (should be done last!)
|
|
'lbHEAD.width = lbHist.width
|
|
'lbHEAD.Left = lbHist.Left
|
|
'lbHEAD.Top = lbHist.Top - (lbHEAD.Height - 1)
|
|
|
|
End Sub
|
|
|
|
Sub delete_selected()
|
|
|
|
Dim logid As Integer
|
|
Dim i As Integer
|
|
Dim fail As Boolean
|
|
Dim proceed As Boolean
|
|
|
|
If MsgBox("Permanently delete these changes?", vbOKCancel) = vbCancel Then
|
|
Exit Sub
|
|
End If
|
|
|
|
|
|
For i = 0 To Me.lbHist.ListCount - 1
|
|
If Me.lbHist.Selected(i) Then
|
|
Call handler.undo_changes(x(i, 6), fail)
|
|
If fail Then
|
|
MsgBox ("undo did not work")
|
|
Exit Sub
|
|
End If
|
|
End If
|
|
Next i
|
|
|
|
shOrders.PivotTables("ptOrders").PivotCache.Refresh
|
|
|
|
Me.lbHist.clear
|
|
Me.Hide
|
|
|
|
End Sub
|