Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' >>>>>>>>>>> MEntryPoints <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- ' Description: This module contains all the routines called by the menus
- ' and shortcut keys. These should all be fairly short routines,
- ' if necessary calling more complex routines in other modules
- '
- ' Authors: Rob Bovey, www.appspro.com
- ' Stephen Bullen, www.oaltd.co.uk
- '
- ' Chapter Change Overview
- ' Ch# Comment
- ' --------------------------------------------------------------
- ' 05 Initial version
- '
- Option Explicit
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- ' Comments: This procedure saves a copy of the completed time
- ' entry workbook to the specified consolidation
- ' location on the network.
- '
- ' Arguments: None
- '
- ' Date Developer Chap Action
- ' --------------------------------------------------------------
- ' 06/01/08 Rob Bovey Ch05 Initial version
- '
- Public Sub PostTimeEntriesToNetwork()
- Dim sSheetTab As String
- Dim sWeekEndDate As String
- Dim sEmployee As String
- Dim sSaveName As String
- Dim sSavePath As String
- Dim wksSheet As Worksheet
- Dim wkbBook As Workbook
- Dim vFullName As Variant
- ' Don't do anything unless our time entry workbook is active
- ' wkbBook will return a reference to it if it is.
- If bIsTimeEntryBookActive(wkbBook) Then
- ' Make sure the TimeEntry worksheet does not have any
- ' data entry errors.
- sSheetTab = sSheetTabName(wkbBook, gsSHEET_TIME_ENTRY)
- Set wksSheet = wkbBook.Worksheets(sSheetTab)
- If wksSheet.Range(gsRNG_HAS_ERRORS).Value Then
- MsgBox gsERR_DATA_ENTRY, vbCritical, gsAPP_NAME
- Exit Sub
- End If
- ' Create a unique name for the time entry workbook.
- sWeekEndDate = Format$( _
- wksSheet.Range(gsRNG_WEEK_END_DATE).Value, _
- "YYYYMMDD")
- sEmployee = wksSheet.Range(gsRNG_EMPLOYEE_NAME).Value
- sSaveName = sWeekEndDate & " - " & sEmployee & ".xls"
- ' Check the registry to determine if we already have a
- ' consolidation path specified. If so, save the time
- ' entry workbook to that location. If not, prompt the
- ' user to identify a consolidation location, save that
- ' location to the registry and save the time entry
- ' workbook to that location.
- sSavePath = GetSetting(gsREG_APP, gsREG_SECTION, _
- gsREG_KEY, "")
- If Len(sSavePath) = 0 Then
- ' No path was stored in the registry. Prompt the
- ' user for one.
- vFullName = Application.GetOpenFilename( _
- Title:=gsCAPTION_SELECT_FOLDER)
- If vFullName <> False Then
- ' NOTE: The InStrRev function was not available
- ' in Excel 97.
- sSavePath = Left$(vFullName, _
- InStrRev(vFullName, "\"))
- SaveSetting gsREG_APP, gsREG_SECTION, _
- gsREG_KEY, sSavePath
- Else
- ' The user cancelled the dialog.
- MsgBox gsMSG_POST_FAIL, vbCritical, gsAPP_NAME
- Exit Sub
- End If
- End If
- wkbBook.SaveCopyAs sSavePath & sSaveName
- MsgBox gsMSG_POST_SUCCESS, vbInformation, gsAPP_NAME
- Else
- MsgBox gsMSG_BOOK_NOT_ACTIVE, vbExclamation, gsAPP_NAME
- End If
- End Sub
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- ' Comments: This procedure allows the user to insert additional
- ' blank data entry rows at the bottom of the data
- ' entry table on the TimeEntry worksheet.
- '
- ' Arguments: None
- '
- ' Date Developer Chap Action
- ' --------------------------------------------------------------
- ' 06/01/08 Rob Bovey Ch05 Initial version
- '
- Public Sub AddMoreRows()
- Const lOFFSET_COLS As Long = 5
- Const lINPUT_COLS As Long = 6
- Dim rngInsert As Range
- Dim wkbBook As Workbook
- Dim wksSheet As Worksheet
- ' Don't do anything unless our time entry workbook is active
- If bIsTimeEntryBookActive(wkbBook) Then
- ' Get a reference to the TimeEntry worksheet and the
- ' insert row range on it. All new rows will be inserted
- ' above this range.
- Set wksSheet = wkbBook.Worksheets(sSheetTabName( _
- wkbBook, gsSHEET_TIME_ENTRY))
- Set rngInsert = wksSheet.Range(gsRNG_INSERT_ROW)
- ' Add a new row to the time entry table.
- wksSheet.Unprotect
- wksSheet.ScrollArea = ""
- rngInsert.EntireRow.Insert
- rngInsert.Offset(-2, 0).EntireRow.Copy _
- Destination:=rngInsert.Offset(-1, 0)
- rngInsert.Offset(-1, lOFFSET_COLS) _
- .Resize(1, lINPUT_COLS).ClearContents
- wksSheet.ScrollArea = _
- wksSheet.Range(gsRNG_SET_SCROLL_AREA).Address
- wksSheet.Protect , True, True, True
- Else
- MsgBox gsMSG_BOOK_NOT_ACTIVE, vbExclamation, gsAPP_NAME
- End If
- End Sub
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- ' Comments: This procedure clears the data entry cells on the
- ' active worksheet so that the worksheet can easily
- ' be reused for a new time period.
- '
- ' Arguments: None
- '
- ' Date Developer Chap Action
- ' --------------------------------------------------------------
- ' 06/01/08 Rob Bovey Ch05 Initial version
- '
- Public Sub ClearDataEntryAreas()
- Dim rngToClear As Range
- Dim wkbBook As Workbook
- ' Don't do anything unless our time entry workbook is active
- If bIsTimeEntryBookActive(wkbBook) Then
- ' Make sure the active worksheet has the rgnClearInputs
- ' defined name.
- On Error Resume Next
- Set rngToClear = _
- wkbBook.ActiveSheet.Range("rgnClearInputs")
- On Error GoTo 0
- ' If the worksheet is an input worksheet, clear the
- ' contents of the input area.
- If Not rngToClear Is Nothing Then
- rngToClear.ClearContents
- End If
- Else
- MsgBox gsMSG_BOOK_NOT_ACTIVE, vbExclamation, gsAPP_NAME
- End If
- End Sub
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- ' Comments: This procedure exits the PETRAS application.
- '
- ' Arguments: None
- '
- ' Date Developer Chap Action
- ' --------------------------------------------------------------
- ' 06/01/08 Rob Bovey Ch05 Initial version
- '
- Public Sub ExitApplication()
- ShutdownApplication
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment