Advertisement
amralomari

VBA

Dec 24th, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function ApproveRejectButton() As Long
  2.   Const SheetID As String = "_Buttonz"
  3.   Dim btnDlg As DialogSheet
  4.    
  5.   Application.ScreenUpdating = False
  6.   On Error Resume Next
  7.   Application.DisplayAlerts = False
  8.   ActiveWorkbook.DialogSheets(SheetID).Delete
  9.   Application.DisplayAlerts = True
  10.   Err.Clear
  11.    
  12.   Set btnDlg = ActiveWorkbook.DialogSheets.Add
  13.    
  14.   With btnDlg
  15.     .Name = SheetID
  16.     .Visible = xlSheetHidden
  17.      
  18.     With .DialogFrame
  19.       .Height = 55
  20.       .Width = 265
  21.       .Caption = "Approve Or Reject Spreadsheet"
  22.     End With
  23.      
  24.     With .Buttons("Button 2")
  25.       .BringToFront
  26.       .Left = 190
  27.       .Top = 42
  28.       .Height = 25
  29.       .Width = 60
  30.       .Caption = "Approve"
  31.     End With
  32.      
  33.     With .Buttons("Button 3")
  34.       .BringToFront
  35.       .Left = 260
  36.       .Top = 42
  37.       .Height = 25
  38.       .Width = 60
  39.       .Caption = "Reject"
  40.     End With
  41.      
  42.     .Labels.Add 80, 40, 100, 60
  43.     .Labels(1).Caption = "Do you want to approve or reject this spreadsheet?"
  44.     Application.ScreenUpdating = True
  45.    
  46.     If .Show = True Then
  47.       ApproveRejectButton = 1
  48.     Else
  49.       ApproveRejectButton = 0
  50.     End If
  51.      
  52.     Application.DisplayAlerts = False
  53.     .Delete
  54.     Application.DisplayAlerts = True
  55.    
  56.   End With
  57. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement