Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-07-2022, 11:18 AM
grNadpa grNadpa is offline Design question: encapsulating excel workbook functions in word 2016 vba project Windows 10 Design question: encapsulating excel workbook functions in word 2016 vba project Office 2016
Advanced Beginner
Design question: encapsulating excel workbook functions in word 2016 vba project
 
Join Date: Mar 2022
Posts: 46
grNadpa is on a distinguished road
Default Design question: encapsulating excel workbook functions in word 2016 vba project

I welcome your thoughts on how to encapsulate my "On Error" statement and label for my word 2016 module that maintains an excel workbook.

I’ve rendered my daughter’s construction business client and vendor names as spreadsheets in an excel 2016 workbook. And I've customized her various waiver, invoice, notary documents and roster maintenance with word 2016 forms.

The only need to invoke the workbook is to initially load the session’s client and vendor rosters, insert a new member or update a member. I’ve created a module I named “modRoster” to address these needs.

I do not want to lock up the workbook for the entire session because only rarely will there be a need for anything but the initial roster load. And that occurs in the initial form’s activation.

Were it not for the opening, closing and error handling for the workbook, the encapsulation is straight forward.
Code:
Function LoadRosters() as Boolean
to load each sheet from the workbook into its own array (I opted not to use collections)
Code:
Function AddRosterRow(pSheetName as String, pRowContent as Variant) as Long
that returns the row number inserted and
Code:
Function UpdateRosterRow(pSheetName as String, pRowContent as Variant, pRowNumber as Long) as Boolean
All three, of course, require opening and closing the workbook and an On Error label given that the error event could happen in any of these functions. (Alas, I have proven that repeatedly.)



Of the options I’ve considered: (1) Encapsulate an additional two functions / subs:
Code:
Function OpenRosterWorkbook(pPathName as string) as Variant
that returns the workbook object and
Code:
Sub ReleaseRosterWorkbook(pRosterObject)
and call them as the first and last statements in the other functions. But, then, where do I put the On Error statement and label without creating a pathological connection?

Or (2) Create an umbrella function that invokes the other functions via a Select Case statement between the opening and close of the workbook. That simplifies where to locate the On Error but requires passing all three parameters to the umbrella function which smells bad to me.

These are the options I’ve considered. And I’m open to an entirely different approach.
Reply With Quote
 

Tags
excel 2016, vba code, word 2016



Similar Threads
Thread Thread Starter Forum Replies Last Post
Another Unique Question for managing a project plan in Excel IamThatGuy Excel 5 02-09-2022 02:10 PM
Excel 2016: A query from same workbook ArviLaanemets Excel 0 01-29-2018 07:22 AM
Macro Personal Workbook does not load in Excel 2016 Intruder Excel Programming 0 01-21-2017 05:44 AM
Design question: encapsulating excel workbook functions in word 2016 vba project Export Project in Excel Workbook codeghi Project 3 09-28-2016 11:32 AM
Newbie VBA question re Excel 2016 Highlander Excel Programming 3 01-22-2016 08:02 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:36 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft