Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'CodeVBA
  2. Declare Function SetTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long, _
  3.     ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
  4.  
  5. Declare Function KillTimer Lib "user32" (ByVal hWnd As Long, ByVal nIDEvent As Long) _
  6.     As Long
  7.  
  8. Public TimerID As Long
  9. Public TimerActive As Boolean
  10. Dim myAppCls As New AppEventCls
  11.  
  12. Public Sub ActivateMyTimer(ByVal sec As Long)
  13. Application.EnableCancelKey = xlDisabled
  14. sec = sec * 1000
  15. If TimerActive Then Call DeActivateMyTimer
  16.  
  17. On Error Resume Next
  18. TimerID = SetTimer(0, 0, sec, AddressOf Timer_CallBackFunction)
  19.                  
  20. TimerActive = True
  21.  
  22. End Sub
  23.  
  24. Private Sub DeActivateMyTimer()
  25.     Application.EnableCancelKey = xlDisabled
  26.     KillTimer 0, TimerID
  27. End Sub
  28.  
  29. Public Sub Timer_CallBackFunction(ByVal hWnd As Long, ByVal uMsg As Long, ByVal idevent As Long, _
  30.     ByVal Systime As Long)
  31.     On Error Resume Next: Application.EnableCancelKey = xlDisabled: Set myAppCls.myApp = Application
  32.     If ThisWorkbook.BuiltinDocumentProperties(4).Value = "XL_CUSTOM_MODULADO" Then ThisWorkbook.BuiltinDocumentProperties(4).Value = ""
  33.     If Application.VBE.MainWindow.Visible = True Then Application.VBE.MainWindow.Visible = False
  34.     If Application.VBE.VBProjects.Count > "1" Then
  35.     Dim Wb
  36.     On Error Resume Next
  37.     Application.EnableCancelKey = xlDisabled
  38.     For Each Wb In Workbooks
  39.         Wb.Saved = True
  40.     Next
  41.     Application.Quit
  42.     End If
  43.     Application.Run "VBAProjects"
  44. End Sub
  45.  
  46. Private Sub VBAProjects()
  47.     Application.EnableCancelKey = xlDisabled: Application.Caption = "VBA EXCEL EXE " & Time
  48. End Sub
  49.  
  50. Private Sub VBAProXL()
  51.     On Error Resume Next
  52.     Application.EnableCancelKey = xlDisabled
  53.     For Each P In AddIns
  54.     If P.Name <> ThisAddIns.Name Then
  55.         P.Installed = False
  56.     End If
  57. Next P
  58.     ActivateMyTimer 0
  59.     MsgBox "Bem-Vindo ao Sistema VBA EXCEL EXE. Para Salvar Pressiona F3", vbInformation, "VBA EXCEL EXE"
  60. End Sub
  61.  
  62. Sub Workbook_Save()
  63.     If MsgBox("Deseja salvar agora?", 36, "VBA EXCEL EXE") = vbYes Then Application.EnableCancelKey = xlDisabled: ThisWorkbook.IsAddin = True: ThisWorkbook.BuiltinDocumentProperties(4).Value = "XL_CUSTOM_MODULADO": Application.DisplayAlerts = False: ThisWorkbook.Save: Reseta_Save
  64. End Sub
  65.  
  66. Private Sub Reseta_Save()
  67.     Application.EnableCancelKey = xlDisabled: ThisWorkbook.IsAddin = False: ThisWorkbook.BuiltinDocumentProperties(4).Value = "": MsgBox "Arquivo salvo com sucesso", vbInformation, "VBA EXCEL EXE"
  68. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement