msfz751

MStandardCode

May 19th, 2014
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' >>>>>>>>>>>   MStandardCode   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  2. ' Description:  Contains standard code library routines that are used
  3. '               without modification in many different projects.
  4. '
  5. ' Authors:      Rob Bovey, www.appspro.com
  6. '               Stephen Bullen, www.oaltd.co.uk
  7. '
  8. ' Chapter Change Overview
  9. ' Ch#   Comment
  10. ' --------------------------------------------------------------
  11. ' 05    Initial version
  12. '
  13. Option Explicit
  14. Option Private Module
  15.  
  16. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  17. ' Comments: Called by all entry point procedures before exiting
  18. '           to ensure that all application properties are
  19. '           correctly restored.
  20. '
  21. ' Arguments:    None
  22. '
  23. ' Date          Developer       Chap    Action
  24. ' --------------------------------------------------------------
  25. ' 06/01/08      Rob Bovey       Ch05    Initial version
  26. '
  27. Public Sub ResetAppProperties()
  28.     Application.StatusBar = False
  29.     Application.ScreenUpdating = True
  30.     Application.DisplayAlerts = True
  31.     Application.EnableEvents = True
  32.     Application.EnableCancelKey = xlInterrupt
  33.     Application.Cursor = xlDefault
  34. End Sub
  35.  
  36.  
  37. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  38. ' Comments: Obtains the sheet tab name of a worksheet from its
  39. '           code name.
  40. '
  41. ' Arguments:    wkbProject      The project workbook to look in.
  42. '               sCodeName       The CodeName of the worksheet whose
  43. '                               sheet tab name you want.
  44. '
  45. ' Returns:      String          The sheet tab name corresponding to sCodeName.
  46. '
  47. ' Date          Developer       Chap    Action
  48. ' --------------------------------------------------------------
  49. ' 06/01/08      Rob Bovey       Ch05    Initial version
  50. '
  51. Public Function sSheetTabName(ByRef wkbProject As Workbook, _
  52.                             ByRef sCodeName As String) As String
  53.     Dim wksSheet As Worksheet
  54.     For Each wksSheet In wkbProject.Worksheets
  55.         If wksSheet.CodeName = sCodeName Then
  56.             sSheetTabName = wksSheet.Name
  57.             Exit For
  58.         End If
  59.     Next wksSheet
  60. End Function
  61.  
  62.  
  63. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  64. ' Comments: This method determines if any visible workbooks are
  65. '           currently open in Excel. This is required so that
  66. '           we don't bomb on machines using personal.xls or a
  67. '           similar hidden workbook.
  68. '
  69. ' Arguments:    None
  70. '
  71. ' Returns:      Long            The number of visible workbooks
  72. '                               currently open in Excel.
  73. '
  74. ' Date          Developer       Chap    Action
  75. ' --------------------------------------------------------------
  76. ' 06/01/08      Rob Bovey       Ch05    Initial version
  77. '
  78. Public Function lCountVisibleWorkbooks() As Long
  79.     Dim lCount As Long
  80.     Dim wkbBook As Workbook
  81.     For Each wkbBook In Application.Workbooks
  82.         If wkbBook.Windows(1).Visible Then
  83.             lCount = lCount + 1
  84.         End If
  85.     Next wkbBook
  86.     lCountVisibleWorkbooks = lCount
  87. End Function
Advertisement
Add Comment
Please, Sign In to add comment