Thank you René, Mark, and Miguel for your input and advice.
René... I could create a new spreadsheet using your example.
Mark... your High, Low Medium example helped me prove the validation process does work.
I think I was struggling with the Workbook, Worksheet definitions.
I got the following code to open an existing Excel spreadsheet, create a NamedList on one of the worksheets, and then use the NamedList as validation for a column on another worksheet. I hope others can use this as an example.
Thanks,
Nigel
int li_ret
OLEObject lole_excel, lole_workbook, lole_sheet
lole_excel = CREATE OLEObject
li_ret = lole_excel.ConnectToNewObject("Excel.Application")
//Make sure we can start up Excel on the local machine
IF li_ret < 0 THEN
DESTROY lole_excel
MessageBox("Connecting to Excel Object Failed", "Error: " + String(li_ret))
Return
END IF
//Allow FileOpen window to resize. Adding '2' as a parameter opens Explorer-style dialog box.
li_ret = GetFileOpenName("Select File", is_import_path, is_import_file, "Doc", "Excel Files (*.xls),*.xls", '', 2)
If li_ret <> 1 then RETURN
//Open the path/filename as an Excel workbook and hide from User
lole_excel.WorkBooks.Open(is_import_path )
//The entire spreadsheet is a Workbook. The rows/columns are on individual Worksheets.
//The main Worksheet is 'Equipment'
//Any additional 'Status' Worksheet contains all valid Equipment Status codes
lole_workbook = lole_excel.application.workbooks(1)
//We dont need to see Excel maximized as we modify it
lole_excel.Application.Visible = True
lole_excel.windowstate = 1 // 1 : Normal, 2 : Minimize, 3 : Maximize
//Each supporting exported Code table should be create as a Named List
//Set the Status sheet as active and the entire column, except heading, as NamedList
lole_excel.Worksheets("Status").Activate
lole_excel.ActiveSheet.range("A2:A65536").Select
lole_excel.range("A2:A65536").Name = "StatusList"
//The main worksheet 'Equipment' has a Status column E that has data (starting in row 3) to be validated against the Named List "StatusList"
//Set the Equipment sheet as active
lole_excel.Worksheets("Equipment").Activate
//Remove any existing validation from column E
lole_excel.Range("E3:E65536").Validation.Delete
//Set the 'Equipment' sheet column E to validate against the 'Status' code list
//Validation Type 3 (Value must be present in a specified list)
//AlertStyle = 1 (Stop)
//Operator = 1 (Between)
lole_excel.Range("E3:E65536").Validation.Add(3, 1, 1, "=StatusList")
//Save the entire Workbook
lole_workbook.Save()
//Quit Excel
lole_excel.Quit()
lole_excel.Disconnectobject()
//Destroy the created OLE object
DESTROY lole_excel
//Cleanup any memory
Garbagecollect()