| Public Function ChangeViewColumnTitle(strViewName As String, vNewTitles As Variant) As String |
| %REM |
| ################################################################################### |
| Goal: |
| change all column titles of a view |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| Arguments: Description: |
| strViewName Name of the view |
| vNewTitles A variant array of strings. Contains the new column values |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| Return: |
| Empty string ("") if function was successful |
| Error message (string) in case of runtime errors |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| Example: |
| Sub Click(Source As Button) |
| Const VIEW_TO_CHANGE$ = "All Addresses" |
| Dim strChangeViewCol As String |
| Dim strNewColumnTitleArray(2) As String |
| strNewColumnTitleArray(0) = "Nachname" |
| strNewColumnTitleArray(1) = "Addresse" |
| strNewColumnTitleArray(2) = "Ort" |
| strChangeViewCol = ChangeViewColumnTitle(VIEW_TO_CHANGE, strNewColumnTitleArray) |
| |
| If strChangeViewCol = "" Then |
| Msgbox "View column titles changed." |
| Else |
| Msgbox strChangeViewCol, 48, "Unexpected error" |
| Exit Sub |
| End If |
| End Sub |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| VERSION / WHEN / WHO / CHANGES |
| 01 02 Dec 2004 TMC (Matthias) new |
| '################################################################################### |
| %END REM |
| |
| On Error Goto ErrHandler |
| |
| Dim session As New NotesSession |
| Dim db As NotesDatabase |
| Dim view As NotesView |
| Dim viewColumn As NotesViewColumn |
| Dim intLoopCount As Integer |
| Set db = session.CurrentDatabase |
| Set view = db.GetView(strViewName) |
| |
| '// Is input value an Array? |
| If Not Isarray (vNewTitles) Then Error 1001, "<vNewTitles> is not an array !" |
| |
| '// Has the input array the same number of elements as the view has? |
| '// REM this out if you do not need that check - so we will just begin with the 1st column and end with the last provided array element. |
| If Not view.ColumnCount = (Ubound(vNewTitles) - Lbound(vNewTitles) + 1) Then |
| Error 1002, "<vNewTitles> does contain a different no. of elements vs. the the no. of columns" |
| End If |
| |
| '// now we loop through the provided array and set the column titles |
| intLoopCount = -1 |
| Forall loop_elem In vNewTitles |
| intLoopCount = intLoopCount + 1 |
| Set viewColumn = view.Columns(intLoopCount) |
| viewColumn.Title = loop_elem 'there is no need for a save, this set property changes the column title ! |
| End Forall |
| |
| '// it seems as if the function was successful, so we return an empty string which indicates the success |
| ChangeViewColumnTitle = "" |
| |
| |
| GoOut: |
| Exit Function |
| ErrHandler: |
| ChangeViewColumnTitle = Error$ & " (Line #" & Erl & ")" |
| Resume GoOut |
| End Function |