ExportButton

WithEvents wrapper that listens to an MSForms.CommandButton on a linelist export sheet and performs a custom export when clicked. The factory wires the button, an optional filter checkbox, and translation/workbook references. On click, RunExport selects a folder, optionally confirms filter usage, then delegates to LLExporter.ExportCustom. The factory returns the concrete class (not IExportButton) because callers hold a reference to keep the WithEvents binding alive.

Depends on: IExportButton, ILLExporter, LLExporter, IApplicationState, ApplicationState, IOSFiles, OSFiles

Factory

Create #

create

Create an export button wrapper

Signature:

Public Function Create(ByVal sourceWkb As Workbook, _
                       ByVal trads As ITranslationObject, _
                       ByVal expBtn As MSForms.CommandButton, _
                       Optional ByVal expChk As MSForms.CheckBox = Nothing) As ExportButton

Factory method that validates the workbook, translations, and button are not Nothing, then wires the WithEvents binding and optional filter checkbox. Called on the predeclared instance. Returns the concrete class (not an interface) because callers hold a reference to keep the WithEvents binding alive.

Parameters:

  • sourceWkb: Workbook. The linelist workbook.
  • trads: ITranslationObject. Translations for user-facing messages.
  • expBtn: MSForms.CommandButton. The button to listen to.
  • expChk: Optional MSForms.CheckBox. Filter checkbox, or Nothing. Defaults to Nothing.

Returns: ExportButton. A wired instance ready to handle click events.

Throws:

  • ProjectError.ObjectNotInitialized When sourceWkb, trads, or expBtn is Nothing.

Public Accessors

ExportNumber #

export-number

Export number derived from button name

Signature:

Public Property Get ExportNumber() As Long

Parses the button Name property by removing the NAMETAG prefix ("CMDExport") and converting the remainder to Long. For example, "CMDExport1" yields 1, "CMDExport3" yields 3.

Returns: Long. The 1-based export number.


UseFilter #

use-filter

Whether the filter checkbox is checked

Signature:

Public Property Get UseFilter() As Boolean

Returns the current value of the filter checkbox. Returns False when no checkbox was bound.

Returns: Boolean. True when the filter checkbox is checked.


Internal members (not exported)

Public Accessors

Self #

self

Current object instance

Signature:

Public Property Get Self() As ExportButton

Returns: ExportButton. The current instance.


SourceWorkbook #

source-workbook-set

Assign the source linelist workbook

Signature:

Public Property Set SourceWorkbook(ByVal wb As Workbook)

Parameters:


Translations #

translations-set

Assign the translations object

Signature:

Public Property Set Translations(ByVal trads As ITranslationObject)

Parameters:


PushButton #

push-button-set

Wire the WithEvents button binding

Signature:

Public Property Set PushButton(ByVal expBtn As MSForms.CommandButton)

Parameters:


FilterCheckBox #

filter-checkbox-set

Assign the optional filter checkbox

Signature:

Public Property Set FilterCheckBox(ByVal expChk As MSForms.CheckBox)

Parameters:


UseFilter #

use-filter-set

Set the filter checkbox value

Signature:

Public Property Let UseFilter(ByVal value As Boolean)

Parameters:


Event Handler

Btn_Click #

btn-click

Handle button click event

Signature:

Private Sub Btn_Click()

RunExport #

run-export

Perform a custom export

Signature:

Private Sub RunExport()

Prompts the user to select a folder via OSFiles, applies busy state, optionally confirms filter usage via MsgBox, then delegates to LLExporter.ExportCustom. On error, displays a translated error message and closes any orphaned output workbook.


SheetTagOf #

Get the sheet type tag from worksheet-level HiddenNames.

Signature:

Private Function SheetTagOf(ByVal sh As Worksheet, _
                            Optional ByVal nameKey As String = "sheet_type") As String

Parameters:

Returns: String. The sheet type tag (HList, VList, etc.).


Private Helpers

TranslatedValue #

translated-value

Get a translated message value

Signature:

Private Function TranslatedValue(ByVal msgCode As String) As String

Parameters:

Returns: String. The translated message text.


UpdateFilteredData #

update-filtered-data

Sync filtered data sheets before a filtered export

Signature:

Private Sub UpdateFilteredData()

Copies HList data to companion filtered sheets and removes hidden or empty rows, ensuring the filtered export reflects the user current filter state.


ThrowError #

throw-error

Raise a ProjectError-based exception

Signature:

Private Sub ThrowError(ByVal errNumber As Long, ByVal message As String)

Parameters:

Throws:


Interface Implementation

IExportButton_ExportNumber #

Signature:

Private Property Get IExportButton_ExportNumber() As Long

Delegation to IExportButton interface members.


Used in (4 file(s))