DesignerEntry

Coordinates clearing, translation, and info read/write actions for a designer entry worksheet. Lazily resolves an IDesignerTranslation translator (for applying language translations and translating message codes) from the host worksheet and its parent workbook. The translator can be replaced via setter injection for testing. Consumers interact through the IDesignerEntry interface.

Depends on: DesignerTranslation, IDesignerTranslation

Factory

create #

Create and configure a designer entry helper

Signature:

Public Function Create(ByVal hostSheet As Worksheet) As IDesignerEntry

Factory method that creates a new DesignerEntry instance, binds it to the supplied worksheet via Configure, and returns the result through the IDesignerEntry interface. Called on the predeclared instance.

Parameters:

  • hostSheet: Worksheet. The worksheet hosting designer inputs.

Returns: IDesignerEntry. A fully initialised instance ready for use.


Public API

configure #

Bind the helper to the target worksheet

Signature:

Public Sub Configure(ByVal hostSheet As Worksheet)

Stores a reference to the host worksheet. Raises an error when the worksheet is Nothing. Does not reset the translator so that a previously injected test double is preserved.

Parameters:

  • hostSheet: Worksheet. The worksheet hosting designer inputs.

Throws:

  • ProjectError.ObjectNotInitialized When the worksheet is Nothing.

use-translator #

Use a provided translations manager instead of creating one

Signature:

Public Sub UseTranslator(ByVal translator As IDesignerTranslation)

Replaces the internally resolved IDesignerTranslation translator with the supplied instance. Primarily used in tests to inject a stub or mock.

Parameters:

  • translator: IDesignerTranslation. The translations provider to use.

clear #

Clear user inputs on the configured worksheet

Signature:

Public Sub Clear()

Resets all input ranges on the configured worksheet by clearing their values and setting backgrounds to white. Also clears any warning messages below the RNG_Warning range. Silently skips any named range that does not exist on the worksheet.


translate #

Translate the configured worksheet using the provided language

Signature:

Public Sub Translate(Optional ByVal language As String = vbNullString)

Delegates to the translations provider to apply translated labels, shapes, and dropdowns to the host worksheet. When a non-empty language string is supplied (e.g. "FRA - Francais"), the translator extracts the language code and persists it to the worksheet-level HiddenName.

Parameters:

  • language: Optional String. Language string in "CODE - Label" format. Defaults to vbNullString.

add-info #

Write a value to a named info range on the host worksheet

Signature:

Public Sub AddInfo(ByVal value As String, ByVal infoName As String)

Maps the logical infoName to its corresponding named range on the host worksheet, writes the value, and sets the background to white. Silently exits when the named range does not exist on the worksheet.

Parameters:

  • value: String. The value to write (path, translated message, etc.).
  • infoName: String. The logical name identifying the target range.

value-of #

Read a value from a named info range on the host worksheet

Signature:

Public Property Get ValueOf(ByVal infoName As String) As String

Maps the logical infoName to its corresponding named range on the host worksheet and returns the current cell value. Returns vbNullString when the named range does not exist.

Parameters:

  • infoName: String. The logical name identifying the source range.

Returns: String. The current value of the named range.


translate-message #

Translate a message code using the designer translations

Signature:

Public Function TranslateMessage(ByVal msgCode As String) As String

Delegates to the lazily resolved translations provider to translate a message code into the current designer language. Returns the raw msgCode unchanged when no translation is available.

Parameters:

  • msgCode: String. The message code to translate.

Returns: String. The translated message text.


host-sheet #

The managed worksheet

Signature:

Public Property Get HostSheet() As Worksheet

Returns the designer entry worksheet that was bound via Configure. Raises an error when accessed before configuration.

Returns: Worksheet. The host worksheet.

Throws:

  • ProjectError.ObjectNotInitialized When the worksheet was not configured.

Internal members (not exported)

Factory

self #

Current object instance

Signature:

Public Property Get Self() As IDesignerEntry

Convenience accessor so consuming code can fluently retrieve the interface reference from the predeclared Create method.

Returns: IDesignerEntry. The current instance cast to the interface.


Internal Helpers

clear-range #

Clear a single named range value and reset its background

Signature:

Private Sub ClearRange(ByVal rngName As String)

Resolves the named range from the host worksheet, sets its value to empty, and resets the background to white. Silently skips when the named range does not exist.

Parameters:


clear-warnings #

Clear the warning range and all contiguous non-empty cells below it

Signature:

Private Sub ClearWarnings()

Resolves RNG_Warning and walks downward, clearing the value and background of each non-empty cell until an empty cell is encountered. Silently exits when RNG_Warning does not exist.


resolve-info-range #

Map a logical info name to its named range on the host worksheet

Signature:

Private Function ResolveInfoRange(ByVal infoName As String) As Range

Resolves an infoName string to the corresponding named range constant, then returns the Range object from the host worksheet. Returns Nothing when the infoName is unknown or the named range does not exist.

Parameters:

Returns: Range. The named range, or Nothing.


resolve-translator #

Lazily resolve or return the translations provider

Signature:

Private Function ResolveTranslator() As IDesignerTranslation

Returns the cached IDesignerTranslation translator, or creates one via DesignerTranslation.Create with the DesignerTranslation worksheet on first access. Raises an error when the translation sheet cannot be found.

Returns: IDesignerTranslation. The translations provider instance.

Throws:


translation-sheet #

Locate the DesignerTranslation worksheet in the parent workbook

Signature:

Private Function TranslationSheet() As Worksheet

Searches the parent workbook of the host worksheet for a sheet named "DesignerTranslation". Raises an error when not found.

Returns: Worksheet. The translations worksheet.

Throws:


raise-error #

Raise a ProjectError-based exception

Signature:

Private Sub RaiseError(ByVal errorCode As ProjectError, ByVal messageText As String)

Wrapper around Err.Raise that standardises the source to CLASS_NAME.

Parameters:

Throws:


Interface Implementation

IDesignerEntry_AddInfo #

Signature:

Private Sub IDesignerEntry_AddInfo(ByVal value As String, ByVal infoName As String)

Delegated members satisfying the IDesignerEntry contract. See the corresponding members above for full documentation.


Used in (4 file(s))