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 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
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.
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 #
Current object instance
Signature:
Public Property Get Self() As ExportButton
Returns: ExportButton. The current instance.
source-workbook-set #
Assign the source linelist workbook
Signature:
Public Property Set SourceWorkbook(ByVal wb As Workbook)
Parameters:
wb: Workbook. The workbook to store.
translations-set #
Assign the translations object
Signature:
Public Property Set Translations(ByVal trads As ITranslationObject)
Parameters:
trads: ITranslationObject. The translations to store.
push-button-set #
Wire the WithEvents button binding
Signature:
Public Property Set PushButton(ByVal expBtn As MSForms.CommandButton)
Parameters:
expBtn: MSForms.CommandButton. The button to listen to.
filter-checkbox-set #
Assign the optional filter checkbox
Signature:
Public Property Set FilterCheckBox(ByVal expChk As MSForms.CheckBox)
Parameters:
expChk: MSForms.CheckBox. The checkbox to bind.
use-filter-set #
Set the filter checkbox value
Signature:
Public Property Let UseFilter(ByVal value As Boolean)
Parameters:
value: Boolean. True to check, False to uncheck.
Event Handler
btn-click #
Handle button click event
Signature:
Private Sub Btn_Click()
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.
Private Helpers
translated-value #
Get a translated message value
Signature:
Private Function TranslatedValue(ByVal msgCode As String) As String
Parameters:
msgCode: String. The message code to translate.
Returns: String. The translated message text.
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.
throw-error #
Raise a ProjectError-based exception
Signature:
Private Sub ThrowError(ByVal errNumber As Long, ByVal message As String)
Parameters:
errNumber: Long. A ProjectError enum value (e.g. ObjectNotInitialized).message: String. Human-readable description of the failure.
Throws:
- ProjectError.
Always raises the specified error.
Interface Implementation
IExportButton_ExportNumber #
Signature:
Private Property Get IExportButton_ExportNumber() As Long
Delegation to IExportButton interface members.