bump product version to 5.0.4.1
[LibreOffice.git] / wizards / source / access2base / DoCmd.xba
blob261aa26b5ce8955aff0ea4de976446b1265f8d34
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3 <script:module xmlns:script="http://openoffice.org/2000/script" script:name="DoCmd" script:language="StarBasic">REM =======================================================================================================================
4 REM === The Access2Base library is a part of the LibreOffice project. ===
5 REM === Full documentation is available on http://www.access2base.com ===
6 REM =======================================================================================================================
8 Option Explicit
10 Type _FindParams
11 FindRecord As Integer &apos; Set to 1 at first invocation of FindRecord
12 FindWhat As Variant
13 Match As Integer
14 MatchCase As Boolean
15 Search As Integer
16 SearchAsFormatted As Boolean &apos; Must be False
17 FindFirst As Boolean
18 OnlyCurrentField As Integer
19 Form As String &apos; Shortcut
20 GridControl As String &apos; Shortcut
21 Target As String &apos; Shortcut
22 LastRow As Long &apos; Last row explored - 0 = before first
23 LastColumn As Integer &apos; Last column explored - 0 ... N-1 index in next arrays; 0 if OnlyCurrentField = acCurrent
24 ColumnNames() As String &apos; Array of column names in grid with boundfield and of same type as FindWhat
25 ResultSetIndex() As Integer &apos; Array of column numbers in ResultSet
26 End Type
28 &apos;Global _gFind As _FindParams
30 Type _Window
31 Frame As Object &apos; com.sun.star.comp.framework.Frame
32 _Name As String &apos; Object Name
33 WindowType As Integer &apos; One of the object types
34 DocumentType As String &apos; Writer, Calc, ... - Only if WindowType = acDocument
35 End Type
37 REM VBA allows call to actions with missing arguments e.g. OpenForm(&quot;aaa&quot;,,&quot;[field]=2&quot;)
38 REM in StarBasic IsMissing requires Variant parameters
40 REM -----------------------------------------------------------------------------------------------------------------------
41 Public Function ApplyFilter( _
42 ByVal Optional pvFilter As Variant _
43 , ByVal Optional pvSQL As Variant _
44 , ByVal Optional pvControlName As Variant _
45 ) As Boolean
46 &apos; Set filter on open table, query, form or subform (if pvControlName present)
48 If _ErrorHandler() Then On Local Error Goto Error_Function
49 Const cstThisSub = &quot;ApplyFilter&quot;
50 Utils._SetCalledSub(cstThisSub)
51 ApplyFilter = False
53 If IsMissing(pvFilter) And IsMissing(pvSQL) Then Call _TraceArguments()
54 If IsMissing(pvFilter) Then pvFilter = &quot;&quot;
55 If Not Utils._CheckArgument(pvFilter, 1, vbString) Then Goto Exit_Function
56 If IsMissing(pvSQL) Then pvSQL = &quot;&quot;
57 If Not Utils._CheckArgument(pvSQL, 1, vbString) Then Goto Exit_Function
58 If IsMissing(pvControlName) Then pvControlName = &quot;&quot;
59 If Not Utils._CheckArgument(pvControlName, 1, vbString) Then Goto Exit_Function
61 Dim sFilter As String, oWindow As Object, oDatabase As Object, oTarget As Object
62 Set oDatabase = Application._CurrentDb()
63 If oDatabase._DbConnect &lt;&gt; DBCONNECTBASE Then Goto Error_NotApplicable
65 If pvSQL &lt;&gt; &quot;&quot; _
66 Then sFilter = oDatabase._ReplaceSquareBrackets(pvSQL) _
67 Else sFilter = oDatabase._ReplaceSquareBrackets(pvFilter)
69 Set oWindow = _SelectWindow()
70 With oWindow
71 Select Case .WindowType
72 Case acForm
73 Set oTarget = _DatabaseForm(._Name, pvControlName)
74 Case acQuery, acTable
75 If pvControlName &lt;&gt; &quot;&quot; Then Goto Exit_Function
76 If IsNull(.Frame.Controller.FormOperations) Then Goto Error_NotApplicable
77 &apos; FormOperations returns &lt;Null&gt; in OpenOffice
78 Set oTarget = .Frame.Controller.FormOperations.Cursor
79 Case Else &apos; Ignore action
80 Goto Exit_Function
81 End Select
82 End With
84 With oTarget
85 .Filter = sFilter
86 .ApplyFilter = True
87 .reload()
88 End With
89 ApplyFilter = True
91 Exit_Function:
92 Utils._ResetCalledSub(cstThisSub)
93 Exit Function
94 Error_NotApplicable:
95 TraceError(TRACEFATAL, ERRACTION, Utils._CalledSub(), 0, 1, cstThisSub)
96 Goto Exit_Function
97 Error_Function:
98 TraceError(TRACEABORT, Err, cstThisSub, Erl)
99 GoTo Exit_Function
100 End Function &apos; ApplyFilter V1.2.0
102 REM -----------------------------------------------------------------------------------------------------------------------
103 Public Function mClose(Optional ByVal pvObjectType As Variant _
104 , Optional ByVal pvObjectName As Variant _
105 , Optional ByVal pvSave As Variant _
106 ) As Boolean
107 If _ErrorHandler() Then On Local Error Goto Error_Function
109 Const cstThisSub = &quot;Close&quot;
110 Utils._SetCalledSub(cstThisSub)
111 mClose = False
112 If IsMissing(pvObjectType) Or IsMissing(pvObjectName) Then Call _TraceArguments()
113 If IsMissing(pvSave) Then pvSave = acSavePrompt
114 If Not (Utils._CheckArgument(pvObjectType, 1, Utils._AddNumeric(), _
115 Array(acTable, acQuery, acForm, acReport)) _
116 And Utils._CheckArgument(pvObjectName, 2, vbString) _
117 And Utils._CheckArgument(pvSave, 3, Utils._AddNumeric(), Array(acSavePrompt)) _
118 ) Then Goto Exit_Function
120 Dim sObjects() As String, sObjectName As String, oController As Object, oObject As Object
121 Dim i As Integer, bFound As Boolean, lComponent As Long
122 Dim oDatabase As Object
123 Set oDatabase = Application._CurrentDb()
124 If oDatabase._DbConnect &lt;&gt; DBCONNECTBASE Then Goto Error_NotApplicable
126 &apos; Check existence of object and find its exact (case-sensitive) name
127 Select Case pvObjectType
128 Case acForm
129 sObjects = oDatabase.Document.getFormDocuments.ElementNames()
130 lComponent = com.sun.star.sdb.application.DatabaseObject.FORM
131 Case acTable
132 sObjects = oDatabase.Connection.getTables.ElementNames()
133 lComponent = com.sun.star.sdb.application.DatabaseObject.TABLE
134 Case acQuery
135 sObjects = oDatabase.Connection.getQueries.ElementNames()
136 lComponent = com.sun.star.sdb.application.DatabaseObject.QUERY
137 Case acReport
138 sObjects = oDatabase.Document.getReportDocuments.ElementNames()
139 lComponent = com.sun.star.sdb.application.DatabaseObject.REPORT
140 End Select
141 bFound = False
142 For i = 0 To UBound(sObjects)
143 If UCase(pvObjectName) = UCase(sObjects(i)) Then
144 sObjectName = sObjects(i)
145 bFound = True
146 Exit For
147 End If
148 Next i
149 If Not bFound Then Goto Trace_NotFound
151 Select Case pvObjectType
152 Case acForm
153 Set oController = oDatabase.Document.getFormDocuments.getByName(sObjectName)
154 mClose = oController.close()
155 Case acTable, acQuery &apos; Not optimal but it works !!
156 Set oController = oDatabase.Document.CurrentController
157 Set oObject = oController.loadComponent(lComponent, sObjectName, False)
158 oObject.frame.close(False)
159 mClose = True
160 Case acReport
161 Set oController = oDatabase.Document.getReportDocuments.getByName(sObjectName)
162 mClose = oController.close()
163 End Select
166 Exit_Function:
167 Set oObject = Nothing
168 Set oController = Nothing
169 Utils._ResetCalledSub(cstThisSub)
170 Exit Function
171 Error_Function:
172 TraceError(TRACEABORT, Err, &quot;Close&quot;, Erl)
173 GoTo Exit_Function
174 Trace_Error:
175 TraceError(TRACEFATAL, ERRCLOSEOBJECT, Utils._CalledSub(), 0, , Array(_GetLabel(Array(&quot;Table&quot;, &quot;Query&quot;, &quot;Form&quot;, &quot;Report&quot;)(pvObjectType)), pvObjectName))
176 Goto Exit_Function
177 Trace_NotFound:
178 TraceError(TRACEFATAL, ERROBJECTNOTFOUND, Utils._CalledSub(), 0, , Array(_GetLabel(Array(&quot;Table&quot;, &quot;Query&quot;, &quot;Form&quot;, &quot;Report&quot;)(pvObjectType)), pvObjectName))
179 Goto Exit_Function
180 Error_NotApplicable:
181 TraceError(TRACEFATAL, ERRMETHOD, Utils._CalledSub(), 0, 1, cstThisSub)
182 Goto Exit_Function
183 End Function &apos; (m)Close V1.1.0
185 REM -----------------------------------------------------------------------------------------------------------------------
186 Public Function CopyObject(ByVal Optional pvDestinationDatabase As Variant _
187 , ByVal Optional pvNewName As Variant _
188 , ByVal Optional pvSourceType As Variant _
189 , ByVal Optional pvSourceName As Variant _
190 ) As Boolean
191 &apos; Copies tables and queries into identical (new) objects
192 If _ErrorHandler() Then On Local Error Goto Error_Function
193 Const cstThisSub = &quot;CopyObject&quot;
194 Utils._SetCalledSub(cstThisSub)
195 CopyObject = False
197 If IsMissing(pvDestinationDatabase) Then pvDestinationDatabase = &quot;&quot;
198 If Not Utils._CheckArgument(pvDestinationDatabase, 1, vbString, &quot;&quot;) Then Goto Exit_Function
199 If IsMissing(pvNewName) Then Call _TraceArguments()
200 If Not Utils._CheckArgument(pvNewName, 2, vbString) Then Goto Exit_Function
201 If IsMissing(pvSourceType) Then Call _TraceArguments()
202 If Not Utils._CheckArgument(pvSourceType, 1, Utils._AddNumeric(), Array(acQuery, acTable) _
203 ) Then Goto Exit_Function
204 If IsMissing(pvSourceName) Then Call _TraceArguments()
205 If Not Utils._CheckArgument(pvSourceName, 2, vbString) Then Goto Exit_Function
207 Dim oSource As Object, oTarget As Object, oDatabase As Object
208 Dim oSourceTable As Object, oSourceColumns As Object, oSourceCol As Object, oTargetCol As Object
209 Dim oSourceKeys As Object, oSourceKey As Object, oTargetKey As Object
210 Dim i As Integer, j As Integer, sSql As String, vPrimaryKeys() As Variant
212 Set oDatabase = Application._CurrentDb()
214 With oDatabase
215 If ._DbConnect &lt;&gt; DBCONNECTBASE Then Goto Error_NotApplicable
216 Select Case pvSourceType
218 Case acQuery
219 Set oSource = .QueryDefs(pvSourceName, True)
220 If IsNull(oSource) Then Goto Error_NotFound
221 Set oTarget = .QueryDefs(pvNewName, True)
222 If Not IsNull(oTarget) Then .Connection.getQueries.dropByName(oTarget.Name) &apos; a query with same name exists already ... drop it
223 If oSource.Query.EscapeProcessing Then
224 Set oTarget = .CreateQueryDef(pvNewName, oSource.SQL)
225 Else
226 Set oTarget = .CreateQueryDef(pvNewName, oSource.SQL, dbSQLPassThrough)
227 End If
228 &apos; Save .odb document
229 .Document.store()
231 Case acTable
232 Set oSource = .TableDefs(pvSourceName, True)
233 If IsNull(oSource) Then Goto Error_NotFound
234 Set oTarget = .TableDefs(pvNewName, True)
235 If Not IsNull(oTarget) Then .Connection.getTables.dropByName(oTarget.Name) &apos; a table with same name exists already ... drop it
236 &apos; Copy source table columns
237 Set oSourceTable = oSource.Table
238 Set oTarget = .Connection.getTables.createDataDescriptor
239 oTarget.Description = oSourceTable.Description
240 oTarget.Name = pvNewName
241 oTarget.Type = oSourceTable.Type
242 Set oSourceColumns = oSourceTable.Columns
243 Set oTargetCol = oTarget.Columns.createDataDescriptor
244 For i = 0 To oSourceColumns.getCount() - 1
245 &apos; Append each individual column to the table descriptor
246 Set oSourceCol = oSourceColumns.getByIndex(i)
247 oTargetCol.Name = oSourceCol.Name
248 oTargetCol.ControlDefault = oSourceCol.ControlDefault
249 oTargetCol.Description = oSourceCol.Description
250 oTargetCol.FormatKey = oSourceCol.FormatKey
251 oTargetCol.HelpText = oSourceCol.HelpText
252 oTargetCol.Hidden = oSourceCol.Hidden
253 oTargetCol.IsCurrency = oSourceCol.IsCurrency
254 oTargetCol.IsNullable = oSourceCol.IsNullable
255 oTargetCol.Precision = oSourceCol.Precision
256 oTargetCol.Scale = oSourceCol.Scale
257 oTargetCol.Type = oSourceCol.Type
258 oTargetCol.TypeName = oSourceCol.TypeName
259 oTarget.Columns.appendByDescriptor(oTargetCol)
260 Next i
261 &apos; Copy keys
262 Set oSourceKeys = oSourceTable.Keys
263 Set oTargetKey = oTarget.Keys.createDataDescriptor()
264 For i = 0 To oSourceKeys.getCount() - 1
265 &apos; Append each key to table descriptor
266 Set oSourceKey = oSourceKeys.getByIndex(i)
267 oTargetKey.DeleteRule = oSourceKey.DeleteRule
268 oTargetKey.Name = oSourceKey.Name
269 oTargetKey.ReferencedTable = oSourceKey.ReferencedTable
270 oTargetKey.Type = oSourceKey.Type
271 &apos; If oSourceKey.Type = com.sun.star.sdbcx.KeyType.PRIMARY Then vPrimaryKeys = oSourceKey.Columns.getElementNames()
272 oTargetKey.UpdateRule = oSourceKey.UpdateRule
273 Set oTargetCol = oTargetKey.Columns.createDataDescriptor()
274 For j = 0 To oSourceKey.Columns.getCount() - 1
275 Set oSourceCol = oSourceKey.Columns.getByIndex(j)
276 oTargetCol.Name = oSourceCol.Name
277 oTargetCol.Description = oSourceCol.Description
278 oTargetCol.IsCurrency = oSourceCol.IsCurrency
279 oTargetCol.IsNullable = oSourceCol.IsNullable
280 oTargetCol.Precision = oSourceCol.Precision
281 oTargetCol.Scale = oSourceCol.Scale
282 oTargetCol.Type = oSourceCol.Type
283 oTargetCol.TypeName = oSourceCol.TypeName
284 oTargetKey.Columns.appendByDescriptor(oTargetCol)
285 Next j
286 oTarget.Keys.appendByDescriptor(oTargetKey)
287 Next i
288 &apos; Duplicate table whole design
289 .Connection.getTables.appendByDescriptor(oTarget)
290 &apos; Copy data
291 sSql = &quot;INSERT INTO [&quot; &amp; pvNewName &amp; &quot;] SELECT [&quot; &amp; oSource.Name &amp; &quot;].* FROM [&quot; &amp; oSource.Name &amp; &quot;]&quot;
292 DoCmd.RunSQL(sSql, dbSQLPassthrough)
294 Case Else
295 End Select
296 End With
298 CopyObject = True
300 Exit_Function:
301 Utils._ResetCalledSub(cstThisSub)
302 Set oSourceCol = Nothing
303 Set oSourceKey = Nothing
304 Set oSourceKeys = Nothing
305 Set oSource = Nothing
306 Set oSourceTable = Nothing
307 Set oSourceColumns = Nothing
308 Set oTargetCol = Nothing
309 Set oTargetKey = Nothing
310 Set oTarget = Nothing
311 Exit Function
312 Error_NotFound:
313 TraceError(TRACEFATAL, ERROBJECTNOTFOUND, Utils._CalledSub(), 0, , Array(Iif(pvSourceType = acQuery, _GetLabel(&quot;QUERY&quot;), _GetLabel(&quot;TABLE&quot;)), pvSourceName))
314 Goto Exit_Function
315 Error_NotApplicable:
316 TraceError(TRACEFATAL, ERRMETHOD, Utils._CalledSub(), 0, 1, cstThisSub)
317 Goto Exit_Function
318 Error_Function:
319 TraceError(TRACEABORT, Err, cstThisSub, Erl)
320 GoTo Exit_Function
321 End Function &apos; CopyObject V1.1.0
323 REM -----------------------------------------------------------------------------------------------------------------------
324 Public Function FindNext() As Boolean
325 &apos; Must be called after a FindRecord
326 &apos; Execute instructions set in FindRecord object
328 If _ErrorHandler() Then On Local Error Goto Error_Function
329 FindNext = False
330 Utils._SetCalledSub(&quot;FindNext&quot;)
332 Dim ofForm As Object, ocGrid As Object
333 Dim i As Integer, lInitialRow As Long, lFindRow As Long
334 Dim bFound As Boolean, b2ndRound As Boolean, bStop As Boolean
335 Dim vFindValue As Variant, oFindrecord As Object
337 Set oFindRecord = _A2B_.FindRecord
338 If IsNull(oFindRecord) Then GoTo Error_FindRecord
339 With oFindRecord
341 If .FindRecord = 0 Then Goto Error_FindRecord
342 .FindRecord = 0
343 Set ofForm = getObject(.Form)
344 If ofForm._Type = OBJCONTROL Then Set ofForm = ofForm.Form &apos; Bug Tombola
345 Set ocGrid = getObject(.GridControl)
347 &apos; Move cursor to the initial row. Operation based on last FindRecord, not on user interactions done inbetween
348 If ofForm.DatabaseForm.RowCount &lt;= 0 then Goto Exit_Function &apos; Dataset is empty
350 lInitialRow = .LastRow &apos; Used if Search = acSearchAll
352 bFound = False
353 lFindRow = .LastRow
354 b2ndRound = False
356 &apos; Last column ? Go to next row
357 If .LastColumn &gt;= UBound(.ColumnNames) Then
358 bStop = False
359 If ofForm.DatabaseForm.isAfterLast() And .Search = acUp Then
360 ofForm.DatabaseForm.last()
361 ElseIf ofForm.DatabaseForm.isLast() And .Search = acSearchAll Then
362 ofForm.DatabaseForm.first()
363 b2ndRound = True
364 ElseIf ofForm.DatabaseForm.isBeforeFirst() And (.Search = acDown Or .Search = acSearchAll) Then
365 ofForm.DatabaseForm.first()
366 ElseIf ofForm.DatabaseForm.isFirst() And .search = acUp Then
367 ofForm.DatabaseForm.beforeFirst()
368 bStop = True
369 ElseIf ofForm.DatabaseForm.isLast() And .search = acDown Then
370 ofForm.DatabaseForm.afterLast()
371 bStop = True
372 ElseIf .Search = acUp Then
373 ofForm.DatabaseForm.previous()
374 Else
375 ofForm.DatabaseForm.next()
376 End If
377 lFindRow = ofForm.DatabaseForm.getRow()
378 If bStop Or (.Search = acSearchAll And lFindRow &gt;= lInitialRow And b2ndRound) Then
379 ofForm.DatabaseForm.absolute(lInitialRow)
380 Exit Do
381 End If
382 .LastColumn = 0
383 Else
384 .LastColumn = .LastColumn + 1
385 End If
387 &apos; Examine column contents
388 If .LastColumn &lt;= UBound(.ColumnNames) Then
389 For i = .LastColumn To UBound(.ColumnNames)
390 vFindValue = Utils._getResultSetColumnValue(ofForm.DatabaseForm.createResultSet(), .ResultSetIndex(i))
391 Select Case VarType(.FindWhat)
392 Case vbDate, vbInteger, vbLong, vbSingle, vbDouble, vbCurrency, vbBigint, vbDecimal
393 bFound = ( .FindWhat = vFindValue )
394 Case vbString
395 Select Case .Match
396 Case acStart
397 If .MatchCase Then
398 bFound = ( Left(.FindWhat, Len(.FindWhat)) = vFindValue )
399 Else
400 bFound = ( UCase(Left(.FindWhat, Len(.FindWhat))) = UCase(vFindValue) )
401 End If
402 Case acAnyWhere
403 If .MatchCase Then
404 bFound = ( InStr(1, vFindValue, .FindWhat, 0) &gt; 0 )
405 Else
406 bFound = ( InStr(vFindValue, .FindWhat) &gt; 0 )
407 End If
408 Case acEntire
409 If .MatchCase Then
410 bFound = ( .FindWhat = vFindValue )
411 Else
412 bFound = ( UCase(.FindWhat) = UCase(vFindValue) )
413 End If
414 End Select
415 End Select
416 If bFound Then
417 .LastColumn = i
418 Exit For
419 End If
420 Next i
421 End If
422 Loop While Not bFound
424 .LastRow = lFindRow
425 If bFound Then
426 ocGrid.Controls(.ColumnNames(.LastColumn)).setFocus()
427 .FindRecord = 1
428 FindNext = True
429 End If
431 End With
433 Exit_Function:
434 Utils._ResetCalledSub(&quot;FindNext&quot;)
435 Exit Function
436 Error_Function:
437 TraceError(TRACEABORT, Err, &quot;FindNext&quot;, Erl)
438 GoTo Exit_Function
439 Error_FindRecord:
440 TraceError(TRACEERRORS, ERRFINDRECORD, Utils._CalledSub(), 0)
441 Goto Exit_Function
442 End Function &apos; FindNext V1.1.0
444 REM -----------------------------------------------------------------------------------------------------------------------
445 Public Function FindRecord(Optional ByVal pvFindWhat As Variant _
446 , Optional ByVal pvMatch As Variant _
447 , Optional ByVal pvMatchCase As Variant _
448 , Optional ByVal pvSearch As Variant _
449 , Optional ByVal pvSearchAsFormatted As Variant _
450 , Optional ByVal pvTargetedField As Variant _
451 , Optional ByVal pvFindFirst As Variant _
452 ) As Boolean
454 &apos;Find a value (string or other) in the underlying data of a gridcontrol
455 &apos;Search in all columns or only in one single control
456 &apos; see pvTargetedField = acAll or acCurrent
457 &apos; pvTargetedField may also be a shortcut to a GridControl or one of its subcontrols
458 &apos;Initialize _Findrecord structure in Database root and call FindNext() to set cursor on found value
460 If _ErrorHandler() Then On Local Error Goto Error_Function
461 FindRecord = False
463 Utils._SetCalledSub(&quot;FindRecord&quot;)
464 If IsMissing(pvFindWhat) Or pvFindWhat = &quot;&quot; Then Call _TraceArguments()
465 If IsMissing(pvMatch) Then pvMatch = acEntire
466 If IsMissing(pvMatchCase) Then pvMatchCase = False
467 If IsMissing(pvSearch) Then pvSearch = acSearchAll
468 If IsMissing(pvSearchAsFormatted) Then pvSearchAsFormatted = False &apos; Anyway only False supported
469 If IsMissing(pvTargetedField) Then pvTargetedField = acCurrent
470 If IsMissing(pvFindFirst) Then pvFindFirst = True
471 If Not (Utils._CheckArgument(pvFindWhat, 1, Utils._AddNumeric(Array(vbString, vbDate))) _
472 And Utils._CheckArgument(pvMatch, 2, Utils._AddNumeric(), Array(acAnywhere, acEntire, acStart)) _
473 And Utils._CheckArgument(pvMatchCase, 3, vbBoolean) _
474 And Utils._CheckArgument(pvSearch, 4, Utils._AddNumeric(), Array(acDown, acSearchAll, acUp)) _
475 And Utils._CheckArgument(pvSearchAsFormatted, 5, vbBoolean, Array(False)) _
476 And Utils._CheckArgument(pvTargetedField, 6, Utils._AddNumeric(vbString)) _
477 And Utils._CheckArgument(pvFindFirst, 7, vbBoolean) _
478 ) Then Exit Function
479 If VarType(pvTargetedField) &lt;&gt; vbString Then
480 If Not Utils._CheckArgument(pvTargetedField, 6, Utils._AddNumeric(), Array(acAll, acCurrent)) Then Exit Function
481 End If
483 Dim ocTarget As Object, i As Integer, j As Integer, vNames() As Variant, iCount As Integer, vIndexes() As Variant
484 Dim vColumn As Variant, vDataField As Variant, ofParentForm As Variant, oColumns As Object, vParentGrid As Object
485 Dim bFound As Boolean, ocGridControl As Object, iFocus As Integer
486 Dim oFindRecord As _FindParams
487 With oFindRecord
488 .FindRecord = 0
489 .FindWhat = pvFindWhat
490 .Match = pvMatch
491 .MatchCase = pvMatchCase
492 .Search = pvSearch
493 .SearchAsFormatted = pvSearchAsFormatted
494 .FindFirst = pvFindFirst
496 &apos; Determine target
497 &apos; Either: pvTargetedField = Grid =&gt; search all fields
498 &apos; pvTargetedField = Control in Grid =&gt; search only in that column
499 &apos; pvTargetedField = acAll or acCurrent =&gt; determine focus
500 Select Case True
502 Case VarType(pvTargetedField) = vbString
503 Set ocTarget = getObject(pvTargetedField)
505 If ocTarget.SubType = CTLGRIDCONTROL Then
506 .OnlyCurrentField = acAll
507 .GridControl = ocTarget._Shortcut
508 .Target = .GridControl
509 ofParentForm = getObject(_getUpperShortcut(ocTarget._Shortcut, ocTarget._Name))
510 If IsNull(ofParentForm.DatabaseForm) Then Goto Error_DatabaseForm
511 Set oColumns = ofParentForm.DatabaseForm.createResultSet().Columns
512 iCount = -1
513 For i = 0 To ocTarget.ControlModel.Count - 1
514 Set vColumn = ocTarget.ControlModel.getByIndex(i)
515 Set vDataField = vColumn.BoundField &apos; examine field type
516 If Not IsNull(vDataField) Then
517 If _CheckColumnType(pvFindWhat, vDataField) Then
518 iCount = iCount + 1
519 ReDim Preserve vNames(0 To iCount)
520 vNames(iCount) = vColumn.Name
521 ReDim Preserve vIndexes(0 To iCount)
522 For j = 0 To oColumns.Count - 1
523 If vDataField.Name = oColumns.ElementNames(j) Then
524 vIndexes(iCount) = j + 1
525 Exit For
526 End If
527 Next j
528 End If
529 End If
530 Next i
532 ElseIf ocTarget._Type = OBJCONTROL Then &apos; Control within a grid tbc
533 If IsNull(ocTarget.ControlModel.BoundField) Then Goto Error_Target &apos; Control MUST be bound to a database record or query
534 &apos; BoundField is in ControlModel, thanks PASTIM !
535 .OnlyCurrentField = acCurrent
536 vParentGrid = getObject(_getUpperShortcut(ocTarget._Shortcut, ocTarget._Name))
537 If vParentGrid.SubType &lt;&gt; CTLGRIDCONTROL Then Goto Error_Target
538 .GridControl = vParentGrid._Shortcut
539 ofParentForm = getObject(_getUpperShortcut(vParentGrid._Shortcut, vParentGrid._Name))
540 If ofParentForm._Type = OBJCONTROL Then Set ofParentForm = ofParentForm.Form &apos; Bug Tombola
541 If IsNull(ofParentForm.DatabaseForm) Then Goto Error_DatabaseForm
542 .Target = ocTarget._Shortcut
543 Set vDataField = ocTarget.ControlModel.BoundField
544 If Not _CheckColumnType(pvFindWhat, vDataField) Then Goto Error_Target
545 ReDim vNames(0), vIndexes(0)
546 vNames(0) = ocTarget._Name
547 Set oColumns = ofParentForm.DatabaseForm.createResultSet().Columns
548 For j = 0 To oColumns.Count - 1
549 If vDataField.Name = oColumns.ElementNames(j) Then
550 vIndexes(0) = j + 1
551 Exit For
552 End If
553 Next j
554 End If
556 Case Else &apos; Determine focus
557 iCount = Application.Forms()._Count
558 If iCount = 0 Then Goto Error_ActiveForm
559 bFound = False
560 For i = 0 To iCount - 1 &apos; Determine form having the focus
561 Set ofParentForm = Application.Forms(i)
562 If ofParentForm.Component.CurrentController.Frame.IsActive() Then
563 bFound = True
564 Exit For
565 End If
566 Next i
567 If Not bFound Then Goto Error_ActiveForm
568 If IsNull(ofParentForm.DatabaseForm) Then Goto Error_DatabaseForm
569 iCount = ofParentForm.Controls().Count
570 bFound = False
571 For i = 0 To iCount - 1
572 Set ocGridControl = ofParentForm.Controls(i)
573 If ocGridControl.SubType = CTLGRIDCONTROL Then
574 bFound = True
575 Exit For
576 End If
577 Next i
578 If Not bFound Then Goto Error_NoGrid
579 .GridControl= ocGridControl._Shortcut
580 iFocus = -1
581 iFocus = ocGridControl.ControlView.getCurrentColumnPosition() &apos; Deprecated but no alternative found !!
583 If pvTargetedField = acAll Or iFocus &lt; 0 Or iFocus &gt;= ocGridControl.ControlModel.Count Then &apos; Has a control within the grid the focus ? NO
584 .OnlyCurrentField = acAll
585 Set oColumns = ofParentForm.DatabaseForm.createResultSet().Columns
586 iCount = -1
587 For i = 0 To ocGridControl.ControlModel.Count - 1
588 Set vColumn = ocGridControl.ControlModel.getByIndex(i)
589 Set vDataField = vColumn.BoundField &apos; examine field type
590 If Not IsNull(vDataField) Then
591 If _CheckColumnType(pvFindWhat, vDataField) Then
592 iCount = iCount + 1
593 ReDim Preserve vNames(0 To iCount)
594 vNames(iCount) = vColumn.Name
595 ReDim Preserve vIndexes(0 To iCount)
596 For j = 0 To oColumns.Count - 1
597 If vDataField.Name = oColumns.ElementNames(j) Then
598 vIndexes(iCount) = j + 1
599 Exit For
600 End If
601 Next j
602 End If
603 End If
604 Next i
606 Else &apos; Has a control within the grid the focus ? YES
607 .OnlyCurrentField = acCurrent
608 Set vColumn = ocGridControl.ControlModel.getByIndex(iFocus)
609 Set ocTarget = ocGridControl.Controls(vColumn.Name)
610 .Target = ocTarget._Shortcut
611 Set vDataField = ocTarget.ControlModel.BoundField
612 If IsNull(vDataField) Then Goto Error_Target &apos; Control MUST be bound to a database record or query
613 If Not _CheckColumnType(pvFindWhat, vDataField) Then Goto Error_Target
614 ReDim vNames(0), vIndexes(0)
615 vNames(0) = ocTarget._Name
616 Set oColumns = ofParentForm.DatabaseForm.createResultSet().Columns
617 For j = 0 To oColumns.Count - 1
618 If vDataField.Name = oColumns.ElementNames(j) Then
619 vIndexes(0) = j + 1
620 Exit For
621 End If
622 Next j
623 End If
625 End Select
627 .Form = ofParentForm._Shortcut
628 .LastColumn = UBound(vNames)
629 .ColumnNames = vNames
630 .ResultSetIndex = vIndexes
631 If pvFindFirst Then
632 Select Case pvSearch
633 Case acDown, acSearchAll
634 ofParentForm.DatabaseForm.beforeFirst()
635 .LastRow = 0
636 Case acUp
637 ofParentForm.DatabaseForm.afterLast()
638 .LastRow = ofParentForm.DatabaseForm.RowCount + 1
639 End Select
640 Else
641 Select Case True
642 Case ofParentForm.DatabaseForm.isBeforeFirst And (pvSearch = acSearchAll Or pvSearch = acDown)
643 .LastRow = 0
644 Case ofParentForm.DatabaseForm.isAfterLast And pvSearch = acUp
645 ofParentForm.DatabaseForm.last() &apos; RowCount produces a wrong value as long as last record has not been reached
646 .LastRow = ofParentForm.DatabaseForm.RowCount + 1
647 Case Else
648 .LastRow = ofParentForm.DatabaseForm.getRow()
649 End Select
650 End If
652 .FindRecord = 1
654 End With
655 Set _A2B_.FindRecord = oFindRecord
656 FindRecord = DoCmd.Findnext()
658 Exit_Function:
659 Utils._ResetCalledSub(&quot;FindRecord&quot;)
660 Exit Function
661 Error_Function:
662 TraceError(TRACEABORT, Err, &quot;FindRecord&quot;, Erl)
663 GoTo Exit_Function
664 Error_ActiveForm:
665 TraceError(TRACEERRORS, ERRNOACTIVEFORM, Utils._CalledSub(), 0)
666 Goto Exit_Function
667 Error_DatabaseForm:
668 TraceError(TRACEFATAL, ERRDATABASEFORM, Utils._CalledSub(), 0, 1, vParentForm._Name)
669 Goto Exit_Function
670 Error_Target:
671 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(), 0, 1, Array(6, pvTargetedField))
672 Goto Exit_Function
673 Error_NoGrid:
674 TraceError(TRACEFATAL, ERRNOGRIDINFORM, Utils._CalledSub(), 0, 1, vParentForm._Name)
675 Goto Exit_Function
676 End Function &apos; FindRecord V1.1.0
678 REM -----------------------------------------------------------------------------------------------------------------------
679 Public Function GetHiddenAttribute(ByVal Optional pvObjectType As Variant _
680 , ByVal Optional pvObjectName As Variant _
681 ) As Boolean
683 If _ErrorHandler() Then On Local Error Goto Error_Function
684 Const cstThisSub = &quot;GetHiddenAttribute&quot;
685 Utils._SetCalledSub(cstThisSub)
687 If IsMissing(pvObjectType) Then Call _TraceArguments()
688 If Not Utils._CheckArgument(pvObjectType, 1, Utils._AddNumeric(), _
689 Array(acDiagram, acForm, acQuery, acTable, acReport, acBasicIDE, acDatabaseWindow, acDocument) _
690 ) Then Goto Exit_Function
691 If IsMissing(pvObjectName) Then
692 Select Case pvObjectType
693 Case acForm, acQuery, acTable, acReport, acDocument : Call _TraceArguments()
694 Case Else
695 End Select
696 pvObjectName = &quot;&quot;
697 Else
698 If Not Utils._CheckArgument(pvObjectName, 2, vbString) Then Goto Exit_Function
699 End If
701 Dim oWindow As Object
702 Set oWindow = _SelectWindow(pvObjectType, pvObjectName)
703 If IsNull(oWindow.Frame) Then Goto Error_NotFound
704 GetHiddenAttribute = Not oWindow.Frame.ContainerWindow.isVisible()
706 Exit_Function:
707 Utils._ResetCalledSub(cstThisSub)
708 Exit Function
709 Error_NotFound:
710 TraceError(TRACEFATAL, ERROBJECTNOTFOUND, Utils._CalledSub(), 0, , Array(_GetLabel(&quot;OBJECT&quot;), pvObjectName))
711 Goto Exit_Function
712 Error_Function:
713 TraceError(TRACEABORT, Err, cstThisSub, Erl)
714 GoTo Exit_Function
715 End Function &apos; GetHiddenAttribute V1.1.0
717 REM -----------------------------------------------------------------------------------------------------------------------
718 Public Function GoToControl(Optional ByVal pvControlName As variant) As Boolean
719 &apos; Set the focus on the named control on the active form.
720 &apos; Return False if the control does not exist or is disabled,
722 If _ErrorHandler() Then On Local Error Goto Error_Function
723 Utils._SetCalledSub(&quot;GoToControl&quot;)
724 If IsMissing(pvControlName) Then Call _TraceArguments()
725 If Not Utils._CheckArgument(pvControlName, 1, vbString) Then Goto Exit_Function
727 GoToControl = False
728 Dim oWindow As Object, ofForm As Object, ocControl As Object
729 Dim i As Integer, iCount As Integer
730 Set oWindow = _SelectWindow()
731 If oWindow.WindowType = acForm Then
732 Set ofForm = Application.Forms(oWindow._Name)
733 iCount = ofForm.Controls().Count
734 For i = 0 To iCount - 1
735 ocControl = ofForm.Controls(i)
736 If UCase(ocControl._Name) = UCase(pvControlName) Then
737 If Methods.hasProperty(ocControl, &quot;Enabled&quot;) Then
738 If ocControl.Enabled Then
739 ocControl.setFocus()
740 GoToControl = True
741 Exit For
742 End If
743 End If
744 End If
745 Next i
746 End If
748 Exit_Function:
749 Utils._ResetCalledSub(&quot;GoToControl&quot;)
750 Exit Function
751 Error_Function:
752 TraceError(TRACEABORT, Err, &quot;GoToControl&quot;, Erl)
753 GoTo Exit_Function
754 End Function &apos; GoToControl V0.9.0
756 REM -----------------------------------------------------------------------------------------------------------------------
757 Public Function GoToRecord(Optional ByVal pvObjectType As Variant _
758 , Optional ByVal pvObjectName As Variant _
759 , Optional ByVal pvRecord As Variant _
760 , Optional ByVal pvOffset As Variant _
761 ) As Boolean
763 &apos;Move to record indicated by pvRecord in the object designated by pvObjectType (MUST BE acDataForm)
765 If _ErrorHandler() Then On Local Error Goto Error_Function
766 GoToRecord = False
768 Const cstThisSub = &quot;GoTorecord&quot;
769 Utils._SetCalledSub(cstThisSub)
770 If IsMissing(pvObjectName) Then pvObjectName = &quot;&quot;
771 If IsMissing(pvObjectType) Then pvObjectType = acActiveDataObject
772 &apos; If IsMissing(pvObjectType) Then
773 &apos; If pvObjectName &lt;&gt; &quot;&quot; Then pvObjectType = acDataForm Else pvObjectType = acActiveDataObject
774 &apos; End If
775 If IsMissing(pvRecord) Then pvRecord = acNext
776 If IsMissing(pvOffset) Then pvOffset = 1
777 If Not (Utils._CheckArgument(pvObjectType, 1, Utils._AddNumeric() _
778 , Array(acActiveDataObject, acDataForm, acDataQuery, acDataTable)) _
779 And Utils._CheckArgument(pvObjectName, 2, vbString) _
780 And Utils._CheckArgument(pvRecord, 3, Utils._AddNumeric() _
781 , Array(acFirst, acGoTo, acLast, acNewRec, acNext, acPrevious)) _
782 And Utils._CheckArgument(pvOffset, 4, Utils._AddNumeric()) _
783 ) Then Goto Exit_Function
784 If pvObjectType = acActiveDataObject And pvObjectName &lt;&gt; &quot;&quot; Then Goto Error_Target
785 If pvOffset &lt; 0 And pvRecord &lt;&gt; acGoTo Then Goto Error_Offset
787 Dim ofForm As Object, oGeneric As Object, oResultSet As Object, oWindow As Object
788 Dim i As Integer, iCount As Integer, bFound As Boolean, lOffset As Long
789 Dim sObjectName, iLengthName As Integer
790 Select Case pvObjectType
791 Case acActiveDataObject
792 Set oWindow = _SelectWindow()
793 With oWindow
794 Select Case .WindowType
795 Case acForm
796 Set oResultSet = _DatabaseForm(._Name, &quot;&quot;)
797 Case acQuery, acTable
798 If IsNull(.Frame.Controller.FormOperations) Then Goto Error_NotApplicable
799 &apos; FormOperations returns &lt;Null&gt; in OpenOffice
800 Set oResultSet = .Frame.Controller.FormOperations.Cursor
801 Case Else &apos; Ignore action
802 Goto Exit_Function
803 End Select
804 End With
805 Case acDataForm
806 &apos; pvObjectName can be &quot;myForm&quot;, &quot;Forms!myForm&quot;, &quot;Forms!myForm!mySubform&quot; or &quot;Forms!myForm!mySubform.Form&quot;
807 sObjectName = UCase(pvObjectName)
808 iLengthName = Len(sObjectName)
809 Select Case True
810 Case iLengthName &gt; 6 And Left(sObjectName, 6) = &quot;FORMS!&quot; And Right(sObjectName, 5) = &quot;.FORM&quot;
811 Set ofForm = getObject(pvObjectName)
812 If ofForm._Type &lt;&gt; OBJSUBFORM Then Goto Error_Target
813 Case iLengthName &gt; 6 And Left(sObjectName, 6) = &quot;FORMS!&quot;
814 Set oGeneric = getObject(pvObjectName)
815 If oGeneric._Type = OBJFORM Or oGeneric._Type = OBJSUBFORM Then
816 Set ofForm = oGeneric
817 ElseIf oGeneric.SubType = CTLSUBFORM Then
818 Set ofForm = oGeneric.Form
819 Else Goto Error_Target
820 End If
821 Case sObjectName = &quot;&quot;
822 Call _TraceArguments()
823 Case Else
824 Set ofForm = Application.Forms(pvObjectName)
825 End Select
826 Set oResultSet = ofForm.DatabaseForm
827 Case acDataQuery
828 Set oWindow = _SelectWindow(acQuery, pvObjectName)
829 If IsNull(oWindow.Frame.Controller.FormOperations) Then Goto Error_NotApplicable
830 &apos; FormOperations returns &lt;Null&gt; in OpenOffice
831 Set oResultSet = oWindow.Frame.Controller.FormOperations.Cursor
832 Case acDataTable
833 Set oWindow = _SelectWindow(acTable, pvObjectName)
834 If IsNull(oWindow.Frame.Controller.FormOperations) Then Goto Error_NotApplicable
835 Set oResultSet = oWindow.Frame.Controller.FormOperations.Cursor
836 Case Else
837 End Select
839 &apos; Check if current row updated =&gt; Save it
840 If oResultSet.IsNew Then
841 oResultSet.insertRow()
842 ElseIf oResultSet.IsModified Then
843 oResultSet.updateRow()
844 End If
846 lOffset = pvOffset
847 Select Case pvRecord
848 Case acFirst : GoToRecord = oResultSet.first()
849 Case acGoTo : GoToRecord = oResultSet.absolute(lOffset)
850 Case acLast : GoToRecord = oResultSet.last()
851 Case acNewRec
852 oResultSet.last() &apos; To simulate the behaviour in the UI
853 oResultSet.moveToInsertRow()
854 GoToRecord = True
855 Case acNext
856 If lOffset = 1 Then
857 GoToRecord = oResultSet.next()
858 Else
859 GoToRecord = oResultSet.relative(lOffset)
860 End If
861 Case acPrevious
862 If lOffset = 1 Then
863 GoToRecord = oResultSet.previous()
864 Else
865 GoToRecord = oResultSet.relative(- lOffset)
866 End If
867 End Select
869 Exit_Function:
870 Utils._ResetCalledSub(cstThisSub)
871 Exit Function
872 Error_Function:
873 TraceError(TRACEABORT, Err, cstThisSub, Erl)
874 GoTo Exit_Function
875 Error_Target:
876 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(), 0, 1, Array(2, pvObjectName))
877 Goto Exit_Function
878 Error_Offset:
879 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(), 0, 1, Array(4, pvOffset))
880 Goto Exit_Function
881 Error_NotApplicable:
882 TraceError(TRACEFATAL, ERRACTION, Utils._CalledSub(), 0, 1, cstThisSub)
883 Goto Exit_Function
884 End Function &apos; GoToRecord
886 REM -----------------------------------------------------------------------------------------------------------------------
887 Public Function Maximize() As Boolean
888 &apos; Maximize the window having the focus
889 Utils._SetCalledSub(&quot;Maximize&quot;)
891 Dim oWindow As Object
892 Maximize = False
893 Set oWindow = _SelectWindow()
894 If Not IsNull(oWindow.Frame) Then
895 If Utils._hasUNOProperty(oWindow.Frame.ContainerWindow, &quot;IsMaximized&quot;) Then oWindow.Frame.ContainerWindow.IsMaximized = True &apos; Ignored when &lt;= OO3.2
896 Maximize = True
897 End If
899 Utils._ResetCalledSub(&quot;Maximize&quot;)
900 Exit Function
901 End Function &apos; Maximize V0.8.5
903 REM -----------------------------------------------------------------------------------------------------------------------
904 Public Function Minimize() As Boolean
905 &apos; Maximize the form having the focus
906 Utils._SetCalledSub(&quot;Minimize&quot;)
908 Dim oWindow As Object
909 Minimize = False
910 Set oWindow = _SelectWindow()
911 If Not IsNull(oWindow.Frame) Then
912 If Utils._hasUNOProperty(oWindow.Frame.ContainerWindow, &quot;IsMinimized&quot;) Then oWindow.Frame.ContainerWindow.IsMinimized = True
913 Minimize = True
914 End If
916 Utils._ResetCalledSub(&quot;Minimize&quot;)
917 Exit Function
918 End Function &apos; Minimize V0.8.5
920 REM -----------------------------------------------------------------------------------------------------------------------
921 Public Function MoveSize(ByVal Optional pvLeft As Variant _
922 , ByVal Optional pvTop As Variant _
923 , ByVal Optional pvWidth As Variant _
924 , ByVal Optional pvHeight As Variant _
925 ) As Variant
926 &apos; Execute MoveSize action
927 If _ErrorHandler() Then On Local Error Goto Error_Function
928 Utils._SetCalledSub(&quot;MoveSize&quot;)
929 MoveSize = False
930 If IsMissing(pvLeft) Then pvLeft = -1
931 If IsMissing(pvTop) Then pvTop = -1
932 If IsMissing(pvWidth) Then pvWidth = -1
933 If IsMissing(pvHeight) Then pvHeight = -1
934 If Not Utils._CheckArgument(pvLeft, 1, Utils._AddNumeric()) Then Goto Exit_Function
935 If Not Utils._CheckArgument(pvTop, 2, Utils._AddNumeric()) Then Goto Exit_Function
936 If Not Utils._CheckArgument(pvWidth, 3, Utils._AddNumeric()) Then Goto Exit_Function
937 If Not Utils._CheckArgument(pvHeight, 4, Utils._AddNumeric()) Then Goto Exit_Function
939 Dim iArg As Integer, iWrong As Integer &apos; Check arguments values
940 iArg = 0
941 If pvHeight &lt; -1 Then
942 iArg = 4 : iWrong = pvHeight
943 ElseIf pvWidth &lt; -1 Then
944 iArg = 3 : iWrong = pvWidth
945 ElseIf pvTop &lt; -1 Then
946 iArg = 2 : iWrong = pvTop
947 ElseIf pvLeft &lt; -1 Then
948 iArg = 1 : iWrong = pvLeft
949 End If
950 If iArg &gt; 0 Then
951 TraceError(TRACEFATAL, ERRWRONGARGUMENT, Utils._CalledSub(), 0, 1, Array(iArg, iWrong))
952 Goto Exit_Function
953 End If
955 Dim iPosSize As Integer
956 iPosSize = 0
957 If pvLeft &gt;= 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.X
958 If pvTop &gt;= 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.Y
959 If pvWidth &gt; 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.WIDTH
960 If pvHeight &gt; 0 Then iPosSize = iPosSize + com.sun.star.awt.PosSize.HEIGHT
962 Dim oWindow As Object
963 Set oWindow = _SelectWindow()
964 With oWindow
965 If Not IsNull(.Frame) Then
966 If Utils._hasUNOProperty(.Frame.ContainerWindow, &quot;IsMaximized&quot;) Then &apos; Ignored when &lt;= OO3.2
967 .Frame.ContainerWindow.IsMaximized = False
968 .Frame.ContainerWindow.IsMinimized = False
969 End If
970 .Frame.ContainerWindow.setPosSize(pvLeft, pvTop, pvWidth, pvHeight, iPosSize)
971 MoveSize = True
972 End If
973 End With
975 Exit_Function:
976 Utils._ResetCalledSub(&quot;MoveSize&quot;)
977 Exit Function
978 Error_Function:
979 TraceError(TRACEABORT, Err, &quot;MoveSize&quot;, Erl)
980 GoTo Exit_Function
981 End Function &apos; MoveSize V1.1.0
983 REM -----------------------------------------------------------------------------------------------------------------------
984 Public Function OpenForm(Optional ByVal pvFormName As Variant _
985 , Optional ByVal pvView As Variant _
986 , Optional ByVal pvFilterName As Variant _
987 , Optional ByVal pvWhereCondition As Variant _
988 , Optional ByVal pvDataMode As Variant _
989 , Optional ByVal pvWindowMode As Variant _
990 , Optional ByVal pvOpenArgs As Variant _
991 ) As Variant
993 If _ErrorHandler() Then On Local Error Goto Error_Function
995 Utils._SetCalledSub(&quot;OpenForm&quot;)
996 If IsMissing(pvFormName) Then Call _TraceArguments()
997 If IsMissing(pvView) Then pvView = acNormal
998 If IsMissing(pvFilterName) Then pvFilterName = &quot;&quot;
999 If IsMissing(pvWhereCondition) Then pvWhereCondition = &quot;&quot;
1000 If IsMissing(pvDataMode) Then pvDataMode = acFormPropertySettings
1001 If IsMissing(pvWindowMode) Then pvWindowMode = acWindowNormal
1002 If IsMissing(pvOpenArgs) Then pvOpenArgs = &quot;&quot;
1003 Set OpenForm = Nothing
1004 If Not (Utils._CheckArgument(pvFormName, 1, vbString) _
1005 And Utils._CheckArgument(pvView, 2, Utils._AddNumeric(), Array(acNormal, acPreview, acDesign)) _
1006 And Utils._CheckArgument(pvFilterName, 3, vbString) _
1007 And Utils._CheckArgument(pvWhereCondition, 4, vbString) _
1008 And Utils._CheckArgument(pvDataMode, 5, Utils._AddNumeric(), Array(acFormAdd, acFormEdit, acFormPropertySettings, acFormReadOnly)) _
1009 And Utils._CheckArgument(pvWindowMode, 6, Utils._AddNumeric(), Array(acDialog, acHidden, acIcon, acWindowNormal)) _
1010 ) Then Goto Exit_Function
1012 Dim ofForm As Object, sWarning As String
1013 Dim oDatabase As Object, oOpenForm As Object, bOpenMode As Boolean, oController As Object
1015 Set oDatabase = Application._CurrentDb()
1016 If oDatabase._DbConnect &lt;&gt; DBCONNECTBASE Then Goto Error_NotApplicable
1018 Set ofForm = Application.AllForms(pvFormName)
1019 If ofForm.IsLoaded Then
1020 sWarning = _GetLabel(&quot;ERR&quot; &amp; ERRFORMYETOPEN)
1021 sWarning = Join(Split(sWarning, &quot;%0&quot;), ofForm._Name)
1022 TraceLog(TRACEANY, &quot;OpenForm: &quot; &amp; sWarning)
1023 Set OpenForm = ofForm
1024 Goto Exit_Function
1025 End If
1026 &apos; Open the form
1027 Select Case pvView
1028 Case acNormal, acPreview: bOpenMode = False
1029 Case acDesign : bOpenMode = True
1030 End Select
1031 Set oController = oDatabase.Document.CurrentController
1032 Set oOpenForm = oController.loadComponent(com.sun.star.sdb.application.DatabaseObject.FORM, ofForm._Name, bOpenMode)
1034 &apos; Apply the filters (FilterName) AND (WhereCondition)
1035 Dim sFilter As String, oForm As Object, oFormsCollection As Object
1036 If pvFilterName = &quot;&quot; And pvWhereCondition = &quot;&quot; Then
1037 sFilter = &quot;&quot;
1038 ElseIf pvFilterName = &quot;&quot; Or pvWhereCondition = &quot;&quot; Then
1039 sFilter = pvFilterName &amp; pvWhereCondition
1040 Else
1041 sFilter = &quot;(&quot; &amp; pvFilterName &amp; &quot;) And (&quot; &amp; pvWhereCondition &amp; &quot;)&quot;
1042 End If
1043 Set oFormsCollection = oOpenForm.DrawPage.Forms
1044 If oFormsCollection.hasByName(&quot;MainForm&quot;) Then
1045 Set oForm = oFormsCollection.getByName(&quot;MainForm&quot;)
1046 ElseIf oFormsCollection.hasByName(&quot;Form&quot;) Then
1047 Set oForm = oFormsCollection.getByName(&quot;Form&quot;)
1048 ElseIf oFormsCollection.hasByName(ofForm._Name) Then
1049 Set oForm = oFormsCollection.getByName(ofForm._Name)
1050 Else
1051 Goto Trace_Error
1052 End If
1053 If sFilter &lt;&gt; &quot;&quot; Then
1054 oForm.Filter = oDatabase._ReplaceSquareBrackets(sFilter)
1055 oForm.ApplyFilter = True
1056 oForm.reload()
1057 ElseIf oForm.Filter &lt;&gt; &quot;&quot; Then &apos; If a filter has been set previously it must be removed
1058 oForm.Filter = &quot;&quot;
1059 oForm.ApplyFilter = False
1060 oForm.reload()
1061 End If
1063 &apos;Housekeeping
1064 Set ofForm = Application.AllForms(pvFormName) &apos; Redone to reinitialize all properties of ofForm now FormName is open
1065 With ofForm
1066 Select Case pvDataMode
1067 Case acFormAdd
1068 .AllowAdditions = True
1069 .AllowDeletions = False
1070 .AllowEdits = False
1071 Case acFormEdit
1072 .AllowAdditions = True
1073 .AllowDeletions = True
1074 .AllowEdits = True
1075 Case acFormReadOnly
1076 .AllowAdditions = False
1077 .AllowDeletions = False
1078 .AllowEdits = False
1079 Case acFormPropertySettings
1080 End Select
1081 .Visible = ( pvWindowMode &lt;&gt; acHidden )
1082 ._OpenArgs = pvOpenArgs
1083 &apos;To avoid AOO 3,4 bug See http://user.services.openoffice.org/en/forum/viewtopic.php?f=13&amp;t=53751
1084 .Component.CurrentController.ViewSettings.ShowOnlineLayout = True
1085 End With
1087 Set OpenForm = ofForm
1089 Exit_Function:
1090 Utils._ResetCalledSub(&quot;OpenForm&quot;)
1091 Set ofForm = Nothing
1092 Set oOpenForm = Nothing
1093 Exit Function
1094 Error_Function:
1095 TraceError(TRACEABORT, Err, &quot;OpenForm&quot;, Erl)
1096 Set OpenForm = Nothing
1097 GoTo Exit_Function
1098 Error_NotApplicable:
1099 TraceError(TRACEFATAL, ERRACTION, Utils._CalledSub(), 0, 1)
1100 Goto Exit_Function
1101 Trace_Error:
1102 TraceError(TRACEFATAL, ERROPENFORM, Utils._CalledSub(), 0, , pvFormName)
1103 Set OpenForm = Nothing
1104 Goto Exit_Function
1105 End Function &apos; OpenForm V0.9.0
1107 REM -----------------------------------------------------------------------------------------------------------------------
1108 Public Function OpenQuery(Optional ByVal pvQueryName As Variant _
1109 , Optional ByVal pvView As Variant _
1110 , Optional ByVal pvDataMode As Variant _
1111 ) As Boolean
1113 If _ErrorHandler() Then On Local Error Goto Error_Function
1115 Utils._SetCalledSub(&quot;OpenQuery&quot;)
1116 If IsMissing(pvQueryName) Then Call _TraceArguments()
1117 If IsMissing(pvView) Then pvView = acViewNormal
1118 If IsMissing(pvDataMode) Then pvDataMode = acEdit
1119 OpenQuery = DoCmd._OpenObject(&quot;Query&quot;, pvQueryName, pvView, pvDataMode)
1121 Exit_Function:
1122 Utils._ResetCalledSub(&quot;OpenQuery&quot;)
1123 Exit Function
1124 Error_Function:
1125 TraceError(TRACEABORT, Err, &quot;OpenQuery&quot;, Erl)
1126 GoTo Exit_Function
1127 End Function &apos; OpenQuery
1129 REM -----------------------------------------------------------------------------------------------------------------------
1130 Public Function OpenReport(Optional ByVal pvReportName As Variant _
1131 , Optional ByVal pvView As Variant _
1132 , Optional ByVal pvDataMode As Variant _
1133 ) As Boolean
1135 If _ErrorHandler() Then On Local Error Goto Error_Function
1137 Utils._SetCalledSub(&quot;OpenReport&quot;)
1138 If IsMissing(pvReportName) Then Call _TraceArguments()
1139 If IsMissing(pvView) Then pvView = acViewNormal
1140 If IsMissing(pvDataMode) Then pvDataMode = acEdit
1141 OpenReport = DoCmd._OpenObject(&quot;Report&quot;, pvReportName, pvView, pvDataMode)
1143 Exit_Function:
1144 Utils._ResetCalledSub(&quot;OpenReport&quot;)
1145 Exit Function
1146 Error_Function:
1147 TraceError(TRACEABORT, Err, &quot;OpenReport&quot;, Erl)
1148 GoTo Exit_Function
1149 End Function &apos; OpenReport
1151 REM -----------------------------------------------------------------------------------------------------------------------
1152 Public Function OpenSQL(Optional ByVal pvSQL As Variant _
1153 , Optional ByVal pvOption As Variant _
1154 ) As Boolean
1155 &apos; Return True if the execution of the SQL statement was successful
1156 &apos; SQL must contain a SELECT query
1157 &apos; pvOption can force pass through mode
1159 If _ErrorHandler() Then On Local Error Goto Error_Function
1161 Utils._SetCalledSub(&quot;OpenSQL&quot;)
1163 OpenSQL = False
1164 If IsMissing(pvSQL) Then Call _TraceArguments()
1165 If Not Utils._CheckArgument(pvSQL, 1, vbString) Then Goto Exit_Function
1166 Const cstNull = -1
1167 If IsMissing(pvOption) Then
1168 pvOption = cstNull
1169 Else
1170 If Not Utils._CheckArgument(pvOption, 2, Utils._AddNumeric(), dbSQLPassThrough) Then Goto Exit_Function
1171 End If
1173 OpenSQL = Application._CurrentDb.OpenSQL(pvSQL, pvOption)
1175 Exit_Function:
1176 Utils._ResetCalledSub(&quot;OpenSQL&quot;)
1177 Exit Function
1178 Error_Function:
1179 TraceError(TRACEABORT, Err, &quot;OpenSQL&quot;, Erl)
1180 GoTo Exit_Function
1181 End Function &apos; OpenSQL V1.1.0
1183 REM -----------------------------------------------------------------------------------------------------------------------
1184 Public Function OpenTable(Optional ByVal pvTableName As Variant _
1185 , Optional ByVal pvView As Variant _
1186 , Optional ByVal pvDataMode As Variant _
1187 ) As Boolean
1189 If _ErrorHandler() Then On Local Error Goto Error_Function
1191 Utils._SetCalledSub(&quot;OpenTable&quot;)
1192 If IsMissing(pvTableName) Then Call _TraceArguments()
1193 If IsMissing(pvView) Then pvView = acViewNormal
1194 If IsMissing(pvDataMode) Then pvDataMode = acEdit
1195 OpenTable = DoCmd._OpenObject(&quot;Table&quot;, pvTableName, pvView, pvDataMode)
1197 Exit_Function:
1198 Utils._ResetCalledSub(&quot;OpenTable&quot;)
1199 Exit Function
1200 Error_Function:
1201 TraceError(TRACEABORT, Err, &quot;OpenTable&quot;, Erl)
1202 GoTo Exit_Function
1203 End Function &apos; OpenTable
1205 REM -----------------------------------------------------------------------------------------------------------------------
1206 Public Function OutputTo(ByVal pvObjectType As Variant _
1207 , ByVal Optional pvObjectName As Variant _
1208 , ByVal Optional pvOutputFormat As Variant _
1209 , ByVal Optional pvOutputFile As Variant _
1210 , ByVal Optional pvAutoStart As Variant _
1211 , ByVal Optional pvTemplateFile As Variant _
1212 , ByVal Optional pvEncoding As Variant _
1213 ) As Boolean
1214 &apos;Supported: acFormatPDF, acFormatODT, acFormatDOC, acFormatHTML for forms
1216 If _ErrorHandler() Then On Local Error Goto Error_Function
1217 Utils._SetCalledSub(&quot;OutputTo&quot;)
1218 OutputTo = False
1220 If Not Utils._CheckArgument(pvObjectType, 1, Utils._AddNumeric(), acSendForm) Then Goto Exit_Function
1221 If IsMissing(pvObjectName) Then pvObjectName = &quot;&quot;
1222 If Not Utils._CheckArgument(pvObjectName, 2, vbString) Then Goto Exit_Function
1223 If IsMissing(pvOutputFormat) Then pvOutputFormat = &quot;&quot;
1224 If Not Utils._CheckArgument(pvOutputFormat, 3, vbString) Then Goto Exit_Function
1225 If pvOutputFormat &lt;&gt; &quot;&quot; Then
1226 If Not Utils._CheckArgument(UCase(pvOutputFormat), 3, vbString, Array( _
1227 UCase(acFormatPDF), UCase(acFormatODT), UCase(acFormatDOC), UCase(acFormatHTML) _
1228 , &quot;PDF&quot;, &quot;ODT&quot;, &quot;DOC&quot;, &quot;HTML&quot;, &quot;&quot; _
1229 )) Then Goto Exit_Function &apos; A 2nd time to allow case unsensitivity
1230 End If
1231 If IsMissing(pvOutputFile) Then pvOutputFile = &quot;&quot;
1232 If Not Utils._CheckArgument(pvOutputFile, 4, vbString) Then Goto Exit_Function
1233 If IsMissing(pvAutoStart) Then pvAutoStart = False
1234 If Not Utils._CheckArgument(pvAutoStart, 5, vbBoolean) Then Goto Exit_Function
1235 If IsMissing(pvTemplateFile) Then pvTemplateFile = &quot;&quot;
1236 If Not Utils._CheckArgument(pvTemplateFile, 6, vbString, &quot;&quot;) Then Goto Exit_Function
1237 If IsMissing(pvEncoding) Then pvEncoding = &quot;&quot;
1238 If Not Utils._CheckArgument(pvEncoding, 7, vbString, &quot;&quot;) Then Goto Exit_Function
1240 Dim vWindow As Variant, sOutputFile As String, ofForm As Object, i As Integer, bFound As Boolean
1241 &apos;Find applicable form
1242 If pvObjectName = &quot;&quot; Then
1243 vWindow = _SelectWindow()
1244 If vWindow.WindowType &lt;&gt; acSendForm Then Goto Error_Action
1245 Set ofForm = Application.Forms(vWindow._Name)
1246 Else
1247 bFound = False
1248 For i = 0 To Application.Forms()._Count - 1
1249 Set ofForm = Application.Forms(i)
1250 If UCase(ofForm._Name) = UCase(pvObjectName) Then
1251 bFound = True
1252 Exit For
1253 End If
1254 Next i
1255 If Not bFound Then Goto Error_NotFound
1256 End If
1258 &apos;Determine format and parameters
1259 Dim sOutputFormat As String, sFilter As String, oFilterData As Object, oExport As Object, sSuffix As String
1260 If pvOutputFormat = &quot;&quot; Then
1261 sOutputFormat = _PromptFormat() &apos; Prompt user for format
1262 If sOutputFormat = &quot;&quot; Then Goto Exit_Function
1263 Else
1264 sOutputFormat = UCase(pvOutputFormat)
1265 End If
1266 Select Case sOutputFormat
1267 Case UCase(acFormatPDF), &quot;PDF&quot;
1268 sFilter = acFormatPDF
1269 oFilterData = Array( _
1270 _MakePropertyValue (&quot;ExportFormFields&quot;, False), _
1272 sSuffix = &quot;pdf&quot;
1273 Case UCase(acFormatDOC), &quot;DOC&quot;
1274 sFilter = acFormatDOC
1275 oFilterData = Array()
1276 sSuffix = &quot;doc&quot;
1277 Case UCase(acFormatODT), &quot;ODT&quot;
1278 sFilter = acFormatODT
1279 oFilterData = Array()
1280 sSuffix = &quot;odt&quot;
1281 Case UCase(acFormatHTML), &quot;HTML&quot;
1282 sFilter = acFormatHTML
1283 oFilterData = Array()
1284 sSuffix = &quot;html&quot;
1285 End Select
1286 oExport = Array( _
1287 _MakePropertyValue(&quot;Overwrite&quot;, True), _
1288 _MakePropertyValue(&quot;FilterName&quot;, sFilter), _
1289 _MakePropertyValue(&quot;FilterData&quot;, oFilterData), _
1292 &apos;Determine output file
1293 If pvOutputFile = &quot;&quot; Then &apos; Prompt file picker to user
1294 sOutputFile = _PromptFilePicker(sSuffix)
1295 If sOutputFile = &quot;&quot; Then Goto Exit_Function
1296 Else
1297 sOutputFile = pvOutputFile
1298 End If
1299 sOutputFile = ConvertToURL(sOutputFile)
1301 &apos;Create file
1302 On Local Error Goto Error_File
1303 ofForm.Component.storeToURL(sOutputFile, oExport)
1304 On Local Error Goto Error_Function
1306 &apos;Launch application, if requested
1307 If pvAutoStart Then Call _ShellExecute(sOutputFile)
1309 OutputTo = True
1311 Exit_Function:
1312 Utils._ResetCalledSub(&quot;OutputTo&quot;)
1313 Exit Function
1314 Error_NotFound:
1315 TraceError(TRACEFATAL, ERROBJECTNOTFOUND, Utils._CalledSub(), 0, , Array(_GetLabel(&quot;OBJECT&quot;), pvObjectName))
1316 Goto Exit_Function
1317 Error_Action:
1318 TraceError(TRACEFATAL, ERRACTION, Utils._CalledSub(), 0)
1319 Goto Exit_Function
1320 Error_Function:
1321 TraceError(TRACEABORT, Err, &quot;OutputTo&quot;, Erl)
1322 GoTo Exit_Function
1323 Error_File:
1324 TraceError(TRACEFATAL, ERRFILENOTCREATED, Utils._CalledSub(), 0, , sOutputFile)
1325 GoTo Exit_Function
1326 End Function &apos; OutputTo V0.9.1
1328 REM -----------------------------------------------------------------------------------------------------------------------
1329 Public Function Quit(Optional ByVal pvSave As Variant) As Variant
1330 &apos; Quit the application
1331 &apos; Modified from Andrew Pitonyak&apos;s Base Macro Programming §5.8.1
1333 If _ErrorHandler() Then On Local Error Goto Error_Function
1334 Const cstThisSub = &quot;Quit&quot;
1335 Utils._SetCalledSub(cstThisSub)
1337 If IsMissing(pvSave) Then pvSave = acQuitSaveAll
1338 If Not Utils._CheckArgument(pvSave, 1, Utils._AddNumeric(), _
1339 Array(acQuitPrompt, acQuitSaveAll, acQuitSaveNone) _
1340 ) Then Goto Exit_Function
1342 Dim oDatabase As Object, oDoc As Object
1343 Set oDatabase = Application._CurrentDb()
1344 If oDatabase._DbConnect &lt;&gt; DBCONNECTBASE Then Goto Error_NotApplicable
1345 If Not IsNull(oDatabase) Then
1346 Set oDoc = oDatabase.Document
1347 Select Case pvSave
1348 Case acQuitPrompt
1349 If MsgBox(_GetLabel(&quot;QUIT&quot;), vbYesNo + vbQuestion, _GetLabel(&quot;QUITSHORT&quot;)) = vbNo Then Exit Function
1350 Case acQuitSaveNone
1351 oDoc.setModified(False)
1352 Case Else
1353 End Select
1354 If HasUnoInterfaces(oDoc, &quot;com.sun.star.util.XCloseable&quot;) Then
1355 If (oDoc.isModified) Then
1356 If (oDoc.hasLocation AND (Not oDoc.isReadOnly)) Then
1357 oDoc.store()
1358 End If
1359 End If
1360 oDoc.close(true)
1361 Else
1362 oDoc.dispose()
1363 End If
1364 End If
1366 Exit_Function:
1367 Utils._ResetCalledSub(cstThisSub)
1368 Set oDatabase = Nothing
1369 Set oDoc = Nothing
1370 Exit Function
1371 Error_Function:
1372 TraceError(TRACEABORT, Err, Utils._CalledSub(), Erl)
1373 Set OpenForm = Nothing
1374 GoTo Exit_Function
1375 Error_NotApplicable:
1376 TraceError(TRACEFATAL, ERRACTION, Utils._CalledSub(), 0, 1, cstThisSub)
1377 Goto Exit_Function
1378 End Function &apos; Quit V1.1.0
1380 REM -----------------------------------------------------------------------------------------------------------------------
1381 Public Sub RunApp(Optional ByVal pvCommandLine As Variant)
1382 &apos; Convert to URL and execute the Command Line
1384 If _ErrorHandler() Then On Local Error Goto Error_Sub
1386 Utils._SetCalledSub(&quot;RunApp&quot;)
1388 If IsMissing(pvCommandLine) Then Call _TraceArguments()
1389 If Not Utils._CheckArgument(pvCommandLine, 1, vbString) Then Goto Exit_Sub
1391 _ShellExecute(ConvertToURL(pvCommandLine))
1393 Exit_Sub:
1394 Utils._ResetCalledSub(&quot;RunApp&quot;)
1395 Exit Sub
1396 Error_Sub:
1397 TraceError(TRACEABORT, Err, &quot;RunApp&quot;, Erl)
1398 GoTo Exit_Sub
1399 End Sub &apos; RunApp V0.8.5
1401 REM -----------------------------------------------------------------------------------------------------------------------
1402 Public Function RunCommand(Optional pvCommand As Variant, Optional pbReturnCommand As Boolean) As Variant
1403 &apos; Execute command via DispatchHelper
1404 &apos; pbReturnCommand = internal parameter to only return the exact command string (always absent if uno prefix present in pvCommand)
1406 If _ErrorHandler() Then On Local Error Goto Exit_Function &apos; Avoid any abort
1407 Const cstThisSub = &quot;RunCommand&quot;
1408 Utils._SetCalledSub(cstThisSub)
1410 Dim iVBACommand As Integer, sOOCommand As String, sDispatch As String
1411 If IsMissing(pvCommand) Then Call _TraceArguments()
1412 If Not ( Utils._CheckArgument(pvCommand, 1, Utils._AddNumeric(vbString)) ) Then Goto Exit_Function
1413 If IsMissing(pbReturnCommand) Then pbReturnCommand = False
1415 RunCommand = True
1417 Const cstUnoPrefix = &quot;.uno:&quot;
1418 If VarType(pvCommand) = vbString Then
1419 sOOCommand = pvCommand
1420 iVBACommand = -1
1421 If _IsLeft(sOOCommand, cstUnoPrefix) Then
1422 Call _DispatchCommand(sOOCommand)
1423 Goto Exit_Function
1424 End If
1425 Else
1426 sOOCommand = &quot;&quot;
1427 iVBACommand = pvCommand
1428 End If
1430 Select Case True
1431 Case iVBACommand = acCmdAboutMicrosoftAccess Or UCase(sOOCommand) = &quot;ABOUT&quot; : sDispatch = &quot;About&quot;
1432 Case iVBACommand = acCmdAboutOpenOffice Or UCase(sOOCommand) = &quot;ABOUT&quot; : sDispatch = &quot;About&quot;
1433 Case iVBACommand = acCmdAboutLibreOffice Or UCase(sOOCommand) = &quot;ABOUT&quot; : sDispatch = &quot;About&quot;
1434 Case UCase(sOOCommand) = &quot;ACTIVEHELP&quot; : sDispatch = &quot;ActiveHelp&quot;
1435 Case UCase(sOOCommand) = &quot;ADDDIRECT&quot; : sDispatch = &quot;AddDirect&quot;
1436 Case UCase(sOOCommand) = &quot;ADDFIELD&quot; : sDispatch = &quot;AddField&quot;
1437 Case UCase(sOOCommand) = &quot;AUTOCONTROLFOCUS&quot; : sDispatch = &quot;AutoControlFocus&quot;
1438 Case UCase(sOOCommand) = &quot;AUTOFILTER&quot; : sDispatch = &quot;AutoFilter&quot;
1439 Case UCase(sOOCommand) = &quot;AUTOPILOTADDRESSDATASOURCE&quot; : sDispatch = &quot;AutoPilotAddressDataSource&quot;
1440 Case UCase(sOOCommand) = &quot;BASICBREAK&quot; : sDispatch = &quot;BasicBreak&quot;
1441 Case iVBACommand = acCmdVisualBasicEditor Or UCase(sOOCommand) = &quot;BASICIDEAPPEAR&quot; : sDispatch = &quot;BasicIDEAppear&quot;
1442 Case UCase(sOOCommand) = &quot;BASICSTOP&quot; : sDispatch = &quot;BasicStop&quot;
1443 Case iVBACommand = acCmdBringToFront Or UCase(sOOCommand) = &quot;BRINGTOFRONT&quot; : sDispatch = &quot;BringToFront&quot;
1444 Case UCase(sOOCommand) = &quot;CHECKBOX&quot; : sDispatch = &quot;CheckBox&quot;
1445 Case UCase(sOOCommand) = &quot;CHOOSEMACRO&quot; : sDispatch = &quot;ChooseMacro&quot;
1446 Case iVBACommand = acCmdClose Or UCase(sOOCommand) = &quot;CLOSEDOC&quot; : sDispatch = &quot;CloseDoc&quot;
1447 Case UCase(sOOCommand) = &quot;CLOSEWIN&quot; : sDispatch = &quot;CloseWin&quot;
1448 Case iVBACommand = acCmdToolbarsCustomize Or UCase(sOOCommand) = &quot;CONFIGUREDIALOG&quot; : sDispatch = &quot;ConfigureDialog&quot;
1449 Case UCase(sOOCommand) = &quot;CONTROLPROPERTIES&quot; : sDispatch = &quot;ControlProperties&quot;
1450 Case iVBACommand = acCmdChangeToCommandButton Or UCase(sOOCommand) = &quot;CONVERTTOBUTTON&quot; : sDispatch = &quot;ConvertToButton&quot;
1451 Case iVBACommand = acCmdChangeToCheckBox Or UCase(sOOCommand) = &quot;CONVERTTOCHECKBOX&quot; : sDispatch = &quot;ConvertToCheckBox&quot;
1452 Case iVBACommand = acCmdChangeToComboBox Or UCase(sOOCommand) = &quot;CONVERTTOCOMBO&quot; : sDispatch = &quot;ConvertToCombo&quot;
1453 Case UCase(sOOCommand) = &quot;CONVERTTOCURRENCY&quot; : sDispatch = &quot;ConvertToCurrency&quot;
1454 Case UCase(sOOCommand) = &quot;CONVERTTODATE&quot; : sDispatch = &quot;ConvertToDate&quot;
1455 Case iVBACommand = acCmdChangeToTextBox Or UCase(sOOCommand) = &quot;CONVERTTOEDIT&quot; : sDispatch = &quot;ConvertToEdit&quot;
1456 Case UCase(sOOCommand) = &quot;CONVERTTOFILECONTROL&quot; : sDispatch = &quot;ConvertToFileControl&quot;
1457 Case iVBACommand = acCmdChangeToLabel Or UCase(sOOCommand) = &quot;CONVERTTOFIXED&quot; : sDispatch = &quot;ConvertToFixed&quot;
1458 Case UCase(sOOCommand) = &quot;CONVERTTOFORMATTED&quot; : sDispatch = &quot;ConvertToFormatted&quot;
1459 Case UCase(sOOCommand) = &quot;CONVERTTOGROUP&quot; : sDispatch = &quot;ConvertToGroup&quot;
1460 Case UCase(sOOCommand) = &quot;CONVERTTOIMAGEBTN&quot; : sDispatch = &quot;ConvertToImageBtn&quot;
1461 Case iVBACommand = acCmdChangeToImage Or UCase(sOOCommand) = &quot;CONVERTTOIMAGECONTROL&quot; : sDispatch = &quot;ConvertToImageControl&quot;
1462 Case iVBACommand = acCmdChangeToListBox Or UCase(sOOCommand) = &quot;CONVERTTOLIST&quot; : sDispatch = &quot;ConvertToList&quot;
1463 Case UCase(sOOCommand) = &quot;CONVERTTONAVIGATIONBAR&quot; : sDispatch = &quot;ConvertToNavigationBar&quot;
1464 Case UCase(sOOCommand) = &quot;CONVERTTONUMERIC&quot; : sDispatch = &quot;ConvertToNumeric&quot;
1465 Case UCase(sOOCommand) = &quot;CONVERTTOPATTERN&quot; : sDispatch = &quot;ConvertToPattern&quot;
1466 Case iVBACommand = acCmdChangeToOptionButton Or UCase(sOOCommand) = &quot;CONVERTTORADIO&quot; : sDispatch = &quot;ConvertToRadio&quot;
1467 Case UCase(sOOCommand) = &quot;CONVERTTOSCROLLBAR&quot; : sDispatch = &quot;ConvertToScrollBar&quot;
1468 Case UCase(sOOCommand) = &quot;CONVERTTOSPINBUTTON&quot; : sDispatch = &quot;ConvertToSpinButton&quot;
1469 Case UCase(sOOCommand) = &quot;CONVERTTOTIME&quot; : sDispatch = &quot;ConvertToTime&quot;
1470 Case iVBACommand = acCmdCopy Or UCase(sOOCommand) = &quot;COPY&quot; : sDispatch = &quot;Copy&quot;
1471 Case UCase(sOOCommand) = &quot;CURRENCYFIELD&quot; : sDispatch = &quot;CurrencyField&quot;
1472 Case iVBACommand = acCmdCut Or UCase(sOOCommand) = &quot;CUT&quot; : sDispatch = &quot;Cut&quot;
1473 Case UCase(sOOCommand) = &quot;DATEFIELD&quot; : sDispatch = &quot;DateField&quot;
1474 Case iVBACommand = acCmdCreateRelationship Or UCase(sOOCommand) = &quot;DBADDRELATION &quot; : sDispatch = &quot;DBAddRelation &quot;
1475 Case UCase(sOOCommand) = &quot;DBCONVERTTOVIEW &quot; : sDispatch = &quot;DBConvertToView &quot;
1476 Case iVBACommand = acCmdDelete Or UCase(sOOCommand) = &quot;DBDELETE &quot; : sDispatch = &quot;DBDelete &quot;
1477 Case UCase(sOOCommand) = &quot;DBDIRECTSQL &quot; : sDispatch = &quot;DBDirectSQL &quot;
1478 Case UCase(sOOCommand) = &quot;DBDSADVANCEDSETTINGS &quot; : sDispatch = &quot;DBDSAdvancedSettings &quot;
1479 Case UCase(sOOCommand) = &quot;DBDSCONNECTIONTYPE &quot; : sDispatch = &quot;DBDSConnectionType &quot;
1480 Case iVBACommand = acCmdDatabaseProperties Or UCase(sOOCommand) = &quot;DBDSPROPERTIES &quot; : sDispatch = &quot;DBDSProperties &quot;
1481 Case UCase(sOOCommand) = &quot;DBEDIT &quot; : sDispatch = &quot;DBEdit &quot;
1482 Case iVBACommand = acCmdSQLView Or UCase(sOOCommand) = &quot;DBEDITSQLVIEW &quot; : sDispatch = &quot;DBEditSqlView &quot;
1483 Case iVBACommand = acCmdRemove Or UCase(sOOCommand) = &quot;DBFORMDELETE &quot; : sDispatch = &quot;DBFormDelete &quot;
1484 Case iVBACommand = acCmdDesignView Or UCase(sOOCommand) = &quot;DBFORMEDIT &quot; : sDispatch = &quot;DBFormEdit &quot;
1485 Case iVBACommand = acCmdFormView Or UCase(sOOCommand) = &quot;DBFORMOPEN &quot; : sDispatch = &quot;DBFormOpen &quot;
1486 Case UCase(sOOCommand) = &quot;DBFORMRENAME &quot; : sDispatch = &quot;DBFormRename &quot;
1487 Case iVBACommand = acCmdNewObjectForm Or UCase(sOOCommand) = &quot;DBNEWFORM &quot; : sDispatch = &quot;DBNewForm &quot;
1488 Case UCase(sOOCommand) = &quot;DBNEWFORMAUTOPILOT &quot; : sDispatch = &quot;DBNewFormAutoPilot &quot;
1489 Case UCase(sOOCommand) = &quot;DBNEWQUERY &quot; : sDispatch = &quot;DBNewQuery &quot;
1490 Case UCase(sOOCommand) = &quot;DBNEWQUERYAUTOPILOT &quot; : sDispatch = &quot;DBNewQueryAutoPilot &quot;
1491 Case UCase(sOOCommand) = &quot;DBNEWQUERYSQL &quot; : sDispatch = &quot;DBNewQuerySql &quot;
1492 Case UCase(sOOCommand) = &quot;DBNEWREPORT &quot; : sDispatch = &quot;DBNewReport &quot;
1493 Case UCase(sOOCommand) = &quot;DBNEWREPORTAUTOPILOT &quot; : sDispatch = &quot;DBNewReportAutoPilot &quot;
1494 Case iVBACommand = acCmdNewObjectTable Or UCase(sOOCommand) = &quot;DBNEWTABLE &quot; : sDispatch = &quot;DBNewTable &quot;
1495 Case UCase(sOOCommand) = &quot;DBNEWTABLEAUTOPILOT &quot; : sDispatch = &quot;DBNewTableAutoPilot &quot;
1496 Case iVBACommand = acCmdNewObjectView Or UCase(sOOCommand) = &quot;DBNEWVIEW &quot; : sDispatch = &quot;DBNewView &quot;
1497 Case UCase(sOOCommand) = &quot;DBNEWVIEWSQL &quot; : sDispatch = &quot;DBNewViewSQL &quot;
1498 Case iVBACommand = acCmdOpenDatabase Or UCase(sOOCommand) = &quot;DBOPEN &quot; : sDispatch = &quot;DBOpen &quot;
1499 Case iVBACommand = acCmdRemove Or UCase(sOOCommand) = &quot;DBQUERYDELETE &quot; : sDispatch = &quot;DBQueryDelete &quot;
1500 Case iVBACommand = acCmdDesignView Or UCase(sOOCommand) = &quot;DBQUERYEDIT &quot; : sDispatch = &quot;DBQueryEdit &quot;
1501 Case iVBACommand = acCmdNewObjectQuery Or UCase(sOOCommand) = &quot;DBQUERYOPEN &quot; : sDispatch = &quot;DBQueryOpen &quot;
1502 Case UCase(sOOCommand) = &quot;DBQUERYRENAME &quot; : sDispatch = &quot;DBQueryRename &quot;
1503 Case UCase(sOOCommand) = &quot;DBREFRESHTABLES &quot; : sDispatch = &quot;DBRefreshTables &quot;
1504 Case iVBACommand = acCmdShowAllRelationships Or UCase(sOOCommand) = &quot;DBRELATIONDESIGN &quot; : sDispatch = &quot;DBRelationDesign &quot;
1505 Case UCase(sOOCommand) = &quot;DBRENAME &quot; : sDispatch = &quot;DBRename &quot;
1506 Case iVBACommand = acCmdRemove Or UCase(sOOCommand) = &quot;DBREPORTDELETE &quot; : sDispatch = &quot;DBReportDelete &quot;
1507 Case iVBACommand = acCmdDesignView Or UCase(sOOCommand) = &quot;DBREPORTEDIT &quot; : sDispatch = &quot;DBReportEdit &quot;
1508 Case iVBACommand = acCmdNewObjectReport Or UCase(sOOCommand) = &quot;DBREPORTOPEN &quot; : sDispatch = &quot;DBReportOpen &quot;
1509 Case UCase(sOOCommand) = &quot;DBREPORTRENAME &quot; : sDispatch = &quot;DBReportRename &quot;
1510 Case iVBACommand = acCmdSelectAll Or UCase(sOOCommand) = &quot;DBSELECTALL &quot; : sDispatch = &quot;DBSelectAll &quot;
1511 Case UCase(sOOCommand) = &quot;DBSHOWDOCINFOPREVIEW &quot; : sDispatch = &quot;DBShowDocInfoPreview &quot;
1512 Case UCase(sOOCommand) = &quot;DBSHOWDOCPREVIEW &quot; : sDispatch = &quot;DBShowDocPreview &quot;
1513 Case iVBACommand = acCmdRemoveTable Or UCase(sOOCommand) = &quot;DBTABLEDELETE &quot; : sDispatch = &quot;DBTableDelete &quot;
1514 Case iVBACommand = acCmdDesignView Or UCase(sOOCommand) = &quot;DBTABLEEDIT &quot; : sDispatch = &quot;DBTableEdit &quot;
1515 Case UCase(sOOCommand) = &quot;DBTABLEFILTER &quot; : sDispatch = &quot;DBTableFilter &quot;
1516 Case iVBACommand = acCmdOpenTable Or UCase(sOOCommand) = &quot;DBTABLEOPEN &quot; : sDispatch = &quot;DBTableOpen &quot;
1517 Case iVBACommand = acCmdRename Or UCase(sOOCommand) = &quot;DBTABLERENAME &quot; : sDispatch = &quot;DBTableRename &quot;
1518 Case UCase(sOOCommand) = &quot;DBUSERADMIN &quot; : sDispatch = &quot;DBUserAdmin &quot;
1519 Case UCase(sOOCommand) = &quot;DBVIEWFORMS &quot; : sDispatch = &quot;DBViewForms &quot;
1520 Case UCase(sOOCommand) = &quot;DBVIEWQUERIES &quot; : sDispatch = &quot;DBViewQueries &quot;
1521 Case UCase(sOOCommand) = &quot;DBVIEWREPORTS &quot; : sDispatch = &quot;DBViewReports &quot;
1522 Case UCase(sOOCommand) = &quot;DBVIEWTABLES &quot; : sDispatch = &quot;DBViewTables &quot;
1523 Case iVBACommand = acCmdDelete Or UCase(sOOCommand) = &quot;DELETE&quot; : sDispatch = &quot;Delete&quot;
1524 Case iVBACommand = acCmdDeleteRecord Or UCase(sOOCommand) = &quot;DELETERECORD&quot; : sDispatch = &quot;DeleteRecord&quot;
1525 Case UCase(sOOCommand) = &quot;DESIGNERDIALOG&quot; : sDispatch = &quot;DesignerDialog&quot;
1526 Case UCase(sOOCommand) = &quot;EDIT&quot; : sDispatch = &quot;Edit&quot;
1527 Case UCase(sOOCommand) = &quot;FIRSTRECORD&quot; : sDispatch = &quot;FirstRecord&quot;
1528 Case UCase(sOOCommand) = &quot;FONTDIALOG&quot; : sDispatch = &quot;FontDialog&quot;
1529 Case UCase(sOOCommand) = &quot;FONTHEIGHT&quot; : sDispatch = &quot;FontHeight&quot;
1530 Case UCase(sOOCommand) = &quot;FORMATTEDFIELD&quot; : sDispatch = &quot;FormattedField&quot;
1531 Case UCase(sOOCommand) = &quot;FORMFILTER&quot; : sDispatch = &quot;FormFilter&quot;
1532 Case iVBACommand = acCmdApplyFilterSort Or UCase(sOOCommand) = &quot;FORMFILTERED&quot; : sDispatch = &quot;FormFiltered&quot;
1533 Case UCase(sOOCommand) = &quot;FORMFILTEREXECUTE&quot; : sDispatch = &quot;FormFilterExecute&quot;
1534 Case UCase(sOOCommand) = &quot;FORMFILTEREXIT&quot; : sDispatch = &quot;FormFilterExit&quot;
1535 Case UCase(sOOCommand) = &quot;FORMFILTERNAVIGATOR&quot; : sDispatch = &quot;FormFilterNavigator&quot;
1536 Case UCase(sOOCommand) = &quot;FORMPROPERTIES&quot; : sDispatch = &quot;FormProperties&quot;
1537 Case UCase(sOOCommand) = &quot;FULLSCREEN&quot; : sDispatch = &quot;FullScreen&quot;
1538 Case UCase(sOOCommand) = &quot;GALLERY&quot; : sDispatch = &quot;Gallery&quot;
1539 Case UCase(sOOCommand) = &quot;GRID&quot; : sDispatch = &quot;Grid&quot;
1540 Case iVBACommand = acCmdSnapToGrid Or UCase(sOOCommand) = &quot;GRIDUSE&quot; : sDispatch = &quot;GridUse&quot;
1541 Case iVBACommand = acCmdViewGrid Or UCase(sOOCommand) = &quot;GRIDVISIBLE&quot; : sDispatch = &quot;GridVisible&quot;
1542 Case UCase(sOOCommand) = &quot;GROUPBOX&quot; : sDispatch = &quot;GroupBox&quot;
1543 Case UCase(sOOCommand) = &quot;HELPINDEX&quot; : sDispatch = &quot;HelpIndex&quot;
1544 Case UCase(sOOCommand) = &quot;HELPSUPPORT&quot; : sDispatch = &quot;HelpSupport&quot;
1545 Case iVBACommand = acCmdInsertHyperlink Or UCase(sOOCommand) = &quot;HYPERLINKDIALOG&quot; : sDispatch = &quot;HyperlinkDialog&quot;
1546 Case UCase(sOOCommand) = &quot;IMAGEBUTTON&quot; : sDispatch = &quot;Imagebutton&quot;
1547 Case UCase(sOOCommand) = &quot;IMAGECONTROL&quot; : sDispatch = &quot;ImageControl&quot;
1548 Case UCase(sOOCommand) = &quot;LABEL&quot; : sDispatch = &quot;Label&quot;
1549 Case iVBACommand = acCmdMaximumRecords Or UCase(sOOCommand) = &quot;LASTRECORD&quot; : sDispatch = &quot;LastRecord&quot;
1550 Case UCase(sOOCommand) = &quot;LISTBOX&quot; : sDispatch = &quot;ListBox&quot;
1551 Case UCase(sOOCommand) = &quot;MACRODIALOG&quot; : sDispatch = &quot;MacroDialog&quot;
1552 Case UCase(sOOCommand) = &quot;MACROORGANIZER&quot; : sDispatch = &quot;MacroOrganizer&quot;
1553 Case UCase(sOOCommand) = &quot;MORECONTROLS&quot; : sDispatch = &quot;MoreControls&quot;
1554 Case UCase(sOOCommand) = &quot;NAVIGATIONBAR&quot; : sDispatch = &quot;NavigationBar&quot;
1555 Case iVBACommand = acCmdObjectBrowser Or UCase(sOOCommand) = &quot;NAVIGATOR&quot; : sDispatch = &quot;Navigator&quot;
1556 Case UCase(sOOCommand) = &quot;NEWDOC&quot; : sDispatch = &quot;NewDoc&quot;
1557 Case UCase(sOOCommand) = &quot;NEWRECORD&quot; : sDispatch = &quot;NewRecord&quot;
1558 Case UCase(sOOCommand) = &quot;NEXTRECORD&quot; : sDispatch = &quot;NextRecord&quot;
1559 Case UCase(sOOCommand) = &quot;NUMERICFIELD&quot; : sDispatch = &quot;NumericField&quot;
1560 Case UCase(sOOCommand) = &quot;OPEN&quot; : sDispatch = &quot;Open&quot;
1561 Case UCase(sOOCommand) = &quot;OPTIONSTREEDIALOG&quot; : sDispatch = &quot;OptionsTreeDialog&quot;
1562 Case UCase(sOOCommand) = &quot;ORGANIZER&quot; : sDispatch = &quot;Organizer&quot;
1563 Case UCase(sOOCommand) = &quot;PARAGRAPHDIALOG&quot; : sDispatch = &quot;ParagraphDialog&quot;
1564 Case iVBACommand = acCmdPaste Or UCase(sOOCommand) = &quot;PASTE&quot; : sDispatch = &quot;Paste&quot;
1565 Case iVBACommand = acCmdPasteSpecial Or UCase(sOOCommand) = &quot;PASTESPECIAL &quot; : sDispatch = &quot;PasteSpecial &quot;
1566 Case UCase(sOOCommand) = &quot;PATTERNFIELD&quot; : sDispatch = &quot;PatternField&quot;
1567 Case UCase(sOOCommand) = &quot;PREVRECORD&quot; : sDispatch = &quot;PrevRecord&quot;
1568 Case iVBACommand = acCmdPrint Or UCase(sOOCommand) = &quot;PRINT&quot; : sDispatch = &quot;Print&quot;
1569 Case UCase(sOOCommand) = &quot;PRINTDEFAULT&quot; : sDispatch = &quot;PrintDefault&quot;
1570 Case UCase(sOOCommand) = &quot;PRINTERSETUP&quot; : sDispatch = &quot;PrinterSetup&quot;
1571 Case iVBACommand = acCmdPrintPreview Or UCase(sOOCommand) = &quot;PRINTPREVIEW&quot; : sDispatch = &quot;PrintPreview&quot;
1572 Case UCase(sOOCommand) = &quot;PUSHBUTTON&quot; : sDispatch = &quot;Pushbutton&quot;
1573 Case UCase(sOOCommand) = &quot;QUIT&quot; : sDispatch = &quot;Quit&quot;
1574 Case UCase(sOOCommand) = &quot;RADIOBUTTON&quot; : sDispatch = &quot;RadioButton&quot;
1575 Case iVBACommand = acCmdSaveRecord Or UCase(sOOCommand) = &quot;RECSAVE&quot; : sDispatch = &quot;RecSave&quot;
1576 Case iVBACommand = acCmdFind Or UCase(sOOCommand) = &quot;RECSEARCH&quot; : sDispatch = &quot;RecSearch&quot;
1577 Case iVBACommand = acCmdUndo Or UCase(sOOCommand) = &quot;RECUNDO&quot; : sDispatch = &quot;RecUndo&quot;
1578 Case iVBACommand = acCmdRefresh Or UCase(sOOCommand) = &quot;REFRESH&quot; : sDispatch = &quot;Refresh&quot;
1579 Case UCase(sOOCommand) = &quot;RELOAD&quot; : sDispatch = &quot;Reload&quot;
1580 Case iVBACommand = acCmdRemoveFilterSort Or UCase(sOOCommand) = &quot;REMOVEFILTERSORT&quot; : sDispatch = &quot;RemoveFilterSort&quot;
1581 Case iVBACommand = acCmdRunMacro Or UCase(sOOCommand) = &quot;RUNMACRO&quot; : sDispatch = &quot;RunMacro&quot;
1582 Case iVBACommand = acCmdSave Or UCase(sOOCommand) = &quot;SAVE&quot; : sDispatch = &quot;Save&quot;
1583 Case UCase(sOOCommand) = &quot;SAVEALL&quot; : sDispatch = &quot;SaveAll&quot;
1584 Case iVBACommand = acCmdSaveAs Or UCase(sOOCommand) = &quot;SAVEAS&quot; : sDispatch = &quot;SaveAs&quot;
1585 Case UCase(sOOCommand) = &quot;SAVEBASICAS&quot; : sDispatch = &quot;SaveBasicAs&quot;
1586 Case UCase(sOOCommand) = &quot;SCRIPTORGANIZER&quot; : sDispatch = &quot;ScriptOrganizer&quot;
1587 Case UCase(sOOCommand) = &quot;SCROLLBAR&quot; : sDispatch = &quot;ScrollBar&quot;
1588 Case iVBACommand = acCmdFind Or UCase(sOOCommand) = &quot;SEARCHDIALOG&quot; : sDispatch = &quot;SearchDialog&quot;
1589 Case iVBACommand = acCmdSelectAll Or UCase(sOOCommand) = &quot;SELECTALL&quot; : sDispatch = &quot;SelectAll&quot;
1590 Case iVBACommand = acCmdSelectAllRecords Or UCase(sOOCommand) = &quot;SELECTALL&quot; : sDispatch = &quot;SelectAll&quot;
1591 Case iVBACommand = acCmdSendToBack Or UCase(sOOCommand) = &quot;SENDTOBACK&quot; : sDispatch = &quot;SendToBack&quot;
1592 Case UCase(sOOCommand) = &quot;SHOWFMEXPLORER&quot; : sDispatch = &quot;ShowFmExplorer&quot;
1593 Case UCase(sOOCommand) = &quot;SIDEBAR&quot; : sDispatch = &quot;Sidebar&quot;
1594 Case iVBACommand = acCmdSortDescending Or UCase(sOOCommand) = &quot;SORTDOWN&quot; : sDispatch = &quot;SortDown&quot;
1595 Case iVBACommand = acCmdSortAscending Or UCase(sOOCommand) = &quot;SORTUP&quot; : sDispatch = &quot;Sortup&quot;
1596 Case UCase(sOOCommand) = &quot;SPINBUTTON&quot; : sDispatch = &quot;SpinButton&quot;
1597 Case UCase(sOOCommand) = &quot;STATUSBARVISIBLE&quot; : sDispatch = &quot;StatusBarVisible&quot;
1598 Case UCase(sOOCommand) = &quot;SWITCHCONTROLDESIGNMODE&quot; : sDispatch = &quot;SwitchControlDesignMode&quot;
1599 Case iVBACommand = acCmdTabOrder Or UCase(sOOCommand) = &quot;TABDIALOG&quot; : sDispatch = &quot;TabDialog&quot;
1600 Case UCase(sOOCommand) = &quot;USEWIZARDS&quot; : sDispatch = &quot;UseWizards&quot;
1601 Case UCase(sOOCommand) = &quot;VERSIONDIALOG&quot; : sDispatch = &quot;VersionDialog&quot;
1602 Case UCase(sOOCommand) = &quot;VIEWDATASOURCEBROWSER&quot; : sDispatch = &quot;ViewDataSourceBrowser&quot;
1603 Case iVBACommand = acCmdDatasheetView Or UCase(sOOCommand) = &quot;VIEWFORMASGRID&quot; : sDispatch = &quot;ViewFormAsGrid&quot;
1604 Case iVBACommand = acCmdZoomSelection Or UCase(sOOCommand) = &quot;ZOOM&quot; : sDispatch = &quot;Zoom&quot;
1605 Case Else
1606 If iVBACommand &gt;= 0 Then Goto Exit_Function
1607 sDispatch = pvCommand
1608 End Select
1610 If pbReturnCommand Then RunCommand = cstUnoPrefix &amp; sDispatch Else Call _DispatchCommand(cstUnoPrefix &amp; sDispatch)
1612 Exit_Function:
1613 Utils._ResetCalledSub(cstThisSub)
1614 Exit Function
1615 Error_Function:
1616 TraceError(TRACEABORT, Err, Utils._CalledSub(), Erl)
1617 GoTo Exit_Function
1618 End Function &apos; RunCommand V0.7.0
1620 REM -----------------------------------------------------------------------------------------------------------------------
1621 Public Function RunSQL(Optional ByVal pvSQL As Variant _
1622 , Optional ByVal pvOption As Variant _
1623 ) As Boolean
1624 &apos; Return True if the execution of the SQL statement was successful
1625 &apos; SQL must contain an ACTION query
1627 If _ErrorHandler() Then On Local Error Goto Error_Function
1629 Utils._SetCalledSub(&quot;RunSQL&quot;)
1631 RunSQL = False
1632 If IsMissing(pvSQL) Then Call _TraceArguments()
1633 If Not Utils._CheckArgument(pvSQL, 1, vbString) Then Goto Exit_Function
1634 Const cstNull = -1
1635 If IsMissing(pvOption) Then
1636 pvOption = cstNull
1637 Else
1638 If Not Utils._CheckArgument(pvOption, 2, Utils._AddNumeric(), dbSQLPassThrough) Then Goto Exit_Function
1639 End If
1641 RunSQL = Application._CurrentDb.RunSQL(pvSQL, pvOption)
1643 Exit_Function:
1644 Utils._ResetCalledSub(&quot;RunSQL&quot;)
1645 Exit Function
1646 Error_Function:
1647 TraceError(TRACEABORT, Err, &quot;RunSQL&quot;, Erl)
1648 GoTo Exit_Function
1649 End Function &apos; RunSQL V1.1.0
1651 REM -----------------------------------------------------------------------------------------------------------------------
1652 Public Function SelectObject( ByVal Optional pvObjectType As Variant _
1653 , ByVal Optional pvObjectName As Variant _
1654 , ByVal Optional pvInDatabaseWindow As Variant _
1655 ) As Boolean
1657 If _ErrorHandler() Then On Local Error Goto Error_Function
1658 Const cstThisSub = &quot;SelectObject&quot;
1659 Utils._SetCalledSub(cstThisSub)
1661 If IsMissing(pvObjectType) Then Call _TraceArguments()
1662 If Not Utils._CheckArgument(pvObjectType, 1, Utils._AddNumeric(), _
1663 Array(acDiagram, acForm, acQuery, acTable, acReport, acBasicIDE, acDatabaseWindow, acDocument) _
1664 ) Then Goto Exit_Function
1665 If IsMissing(pvObjectName) Then
1666 Select Case pvObjectType
1667 Case acForm, acQuery, acTable, acReport, acDocument : Call _TraceArguments()
1668 Case Else
1669 End Select
1670 pvObjectName = &quot;&quot;
1671 Else
1672 If Not Utils._CheckArgument(pvObjectName, 2, vbString) Then Goto Exit_Function
1673 End If
1674 If Not IsMissing(pvInDatabaseWindow) Then
1675 If Not Utils._CheckArgument(pvInDatabaseWindow, 3, vbBoolean, False) Then Goto Exit_Function
1676 End If
1678 Dim oWindow As Object
1679 Set oWindow = _SelectWindow(pvObjectType, pvObjectName)
1680 If IsNull(oWindow.Frame) Then Goto Error_NotFound
1681 With oWindow.Frame.ContainerWindow
1682 If .isVisible() = False Then .setVisible(True)
1683 .IsMinimized = False
1684 .setFocus()
1685 .setEnable(True) &apos; Added to try to bypass desynchro issue in Linux
1686 .toFront() &apos; Added to force window change in Linux
1687 End With
1689 Exit_Function:
1690 Utils._ResetCalledSub(cstThisSub)
1691 Exit Function
1692 Error_NotFound:
1693 TraceError(TRACEFATAL, ERROBJECTNOTFOUND, Utils._CalledSub(), 0, , Array(_GetLabel(&quot;OBJECT&quot;), pvObjectName))
1694 Goto Exit_Function
1695 Error_Function:
1696 TraceError(TRACEABORT, Err, cstThisSub, Erl)
1697 GoTo Exit_Function
1698 End Function &apos; SelectObject V1.1.0
1700 REM -----------------------------------------------------------------------------------------------------------------------
1701 Public Function SendObject(ByVal Optional pvObjectType As Variant _
1702 , ByVal Optional pvObjectName As Variant _
1703 , ByVal Optional pvOutputFormat As Variant _
1704 , ByVal Optional pvTo As Variant _
1705 , ByVal Optional pvCc As Variant _
1706 , ByVal Optional pvBcc As Variant _
1707 , ByVal Optional pvSubject As Variant _
1708 , ByVal Optional pvMessageText As Variant _
1709 , ByVal Optional pvEditMessage As Variant _
1710 , ByVal Optional pvTemplateFile As Variant _
1711 ) As Boolean
1712 &apos;Supported: acFormatPDF, acFormatODT, acFormatDOC, acFormatHTML for forms
1713 &apos;To be prepared: acFormatCSV and acFormatODS for tables/queries ?
1714 If _ErrorHandler() Then On Local Error Goto Error_Function
1715 Utils._SetCalledSub(&quot;SendObject&quot;)
1716 SendObject = False
1718 If IsMissing(pvObjectType) Then pvObjectType = acSendNoObject
1719 If Not Utils._CheckArgument(pvObjectType, 1, Utils._AddNumeric(), Array(acSendNoObject, acSendForm)) Then Goto Exit_Function
1720 If IsMissing(pvObjectName) Then pvObjectName = &quot;&quot;
1721 If Not Utils._CheckArgument(pvObjectName, 2,vbString) Then Goto Exit_Function
1722 If IsMissing(pvOutputFormat) Then pvOutputFormat = &quot;&quot;
1723 If Not Utils._CheckArgument(pvOutputFormat, 3, vbString) Then Goto Exit_Function
1724 If pvOutputFormat &lt;&gt; &quot;&quot; Then
1725 If Not Utils._CheckArgument(UCase(pvOutputFormat), 3, vbString, Array( _
1726 UCase(acFormatPDF), UCase(acFormatODT), UCase(acFormatDOC), UCase(acFormatHTML) _
1727 , &quot;PDF&quot;, &quot;ODT&quot;, &quot;DOC&quot;, &quot;HTML&quot;, &quot;&quot; _
1728 )) Then Goto Exit_Function &apos; A 2nd time to allow case unsensitivity
1729 End If
1730 If IsMissing(pvTo) Then pvTo = &quot;&quot;
1731 If Not Utils._CheckArgument(pvTo, 4, vbString) Then Goto Exit_Function
1732 If IsMissing(pvCc) Then pvCc = &quot;&quot;
1733 If Not Utils._CheckArgument(pvCc, 5, vbString) Then Goto Exit_Function
1734 If IsMissing(pvBcc) Then pvBcc = &quot;&quot;
1735 If Not Utils._CheckArgument(pvBcc, 6, vbString) Then Goto Exit_Function
1736 If IsMissing(pvSubject) Then pvSubject = &quot;&quot;
1737 If Not Utils._CheckArgument(pvSubject, 7, vbString) Then Goto Exit_Function
1738 If IsMissing(pvMessageText) Then pvMessageText = &quot;&quot;
1739 If Not Utils._CheckArgument(pvMessageText, 8, vbString) Then Goto Exit_Function
1740 If IsMissing(pvEditMessage) Then pvEditMessage = True
1741 If Not Utils._CheckArgument(pvEditMessage, 9, vbBoolean) Then Goto Exit_Function
1742 If IsMissing(pvTemplateFile) Then pvTemplateFile = &quot;&quot;
1743 If Not Utils._CheckArgument(pvTemplateFile,10, vbString, &quot;&quot;) Then Goto Exit_Function
1745 Dim vTo() As Variant, vCc() As Variant, vBcc() As Variant, oWindow As Object
1746 Dim sDirectory As String, sOutputFile As String, sSuffix As String, sOutputFormat As String
1747 Const cstSemiColon = &quot;;&quot;
1748 If pvTo &lt;&gt; &quot;&quot; Then vTo() = Split(pvTo, cstSemiColon) Else vTo() = Array()
1749 If pvCc &lt;&gt; &quot;&quot; Then vCc() = Split(pvCc, cstSemiColon) Else vCc() = Array()
1750 If pvBcc &lt;&gt; &quot;&quot; Then vBcc() = Split(pvBcc, cstSemiColon) Else vBcc() = Array()
1751 Select Case True
1752 Case pvObjectType = acSendNoObject And pvObjectName = &quot;&quot;
1753 SendObject = _SendWithoutAttachment(vTo, vCc, vBcc, pvSubject, pvMessageText)
1754 Case Else
1755 If pvObjectType = acSendNoObject And pvObjectName &lt;&gt; &quot;&quot; Then
1756 If Not FileExists(pvObjectName) Then Goto Error_File
1757 sOutputFile = pvObjectName
1758 Else &apos; OutputFile has to be created
1759 If pvObjectType &lt;&gt; acSendNoObject And pvObjectName = &quot;&quot; Then
1760 oWindow = _SelectWindow()
1761 If oWindow.WindowType &lt;&gt; acSendForm Then Goto Error_Action
1762 pvObjectType = acSendForm
1763 pvObjectName = oWindow._Name
1764 End If
1765 sDirectory = _getTempDirectoryURL()
1766 If Right(sDirectory, 1) &lt;&gt; &quot;/&quot; Then sDirectory = sDirectory &amp; &quot;/&quot;
1767 If pvOutputFormat = &quot;&quot; Then
1768 sOutputFormat = _PromptFormat() &apos; Prompt user for format
1769 If sOutputFormat = &quot;&quot; Then Goto Exit_Function
1770 Else
1771 sOutputFormat = UCase(pvOutputFormat)
1772 End If
1773 Select Case sOutputFormat
1774 Case UCase(acFormatPDF), &quot;PDF&quot; : sSuffix = &quot;pdf&quot;
1775 Case UCase(acFormatDOC), &quot;DOC&quot; : sSuffix = &quot;doc&quot;
1776 Case UCase(acFormatODT), &quot;ODT&quot; : sSuffix = &quot;odt&quot;
1777 Case UCase(acFormatHTML), &quot;HTML&quot; : sSuffix = &quot;html&quot;
1778 End Select
1779 sOutputFile = sDirectory &amp; pvObjectName &amp; &quot;.&quot; &amp; sSuffix
1780 If Not OutputTo(pvObjectType, pvObjectName, sOutputFormat, sOutputFile, False) Then Goto Exit_Function
1781 End If
1782 SendObject = _SendWithAttachment(vTo, vCc, vBcc, pvSubject, Array(sOutputFile), pvMessageText, pvEditMessage)
1783 End Select
1785 Exit_Function:
1786 Utils._ResetCalledSub(&quot;SendObject&quot;)
1787 Exit Function
1788 Error_NotFound:
1789 TraceError(TRACEFATAL, ERROBJECTNOTFOUND, Utils._CalledSub(), 0, , Array(_GetLabel(&quot;OBJECT&quot;), pvObjectName))
1790 Goto Exit_Function
1791 Error_Function:
1792 TraceError(TRACEABORT, Err, &quot;SendObject&quot;, Erl)
1793 GoTo Exit_Function
1794 Error_Action:
1795 TraceError(TRACEFATAL, ERRACTION, Utils._CalledSub(), 0)
1796 Goto Exit_Function
1797 Error_File:
1798 TraceError(TRACEFATAL, ERRFILEACCESS, Utils._CalledSub(), 0, , pvObjectName)
1799 Goto Exit_Function
1800 End Function &apos; SendObject V0.8.5
1802 REM -----------------------------------------------------------------------------------------------------------------------
1803 Public Function SetHiddenAttribute(ByVal Optional pvObjectType As Variant _
1804 , ByVal Optional pvObjectName As Variant _
1805 , ByVal Optional pvHidden As Variant _
1806 ) As Boolean
1808 If _ErrorHandler() Then On Local Error Goto Error_Function
1809 SetHiddenAttribute = False
1810 Const cstThisSub = &quot;SetHiddenAttribute&quot;
1811 Utils._SetCalledSub(cstThisSub)
1813 If IsMissing(pvObjectType) Then Call _TraceArguments()
1814 If Not Utils._CheckArgument(pvObjectType, 1, Utils._AddNumeric(), _
1815 Array(acDiagram, acForm, acQuery, acTable, acReport, acBasicIDE, acDatabaseWindow), acDocument _
1816 ) Then Goto Exit_Function
1817 If IsMissing(pvObjectName) Then
1818 Select Case pvObjectType
1819 Case acForm, acQuery, acTable, acReport, acDocument : Call _TraceArguments()
1820 Case Else
1821 End Select
1822 pvObjectName = &quot;&quot;
1823 Else
1824 If Not Utils._CheckArgument(pvObjectName, 2, vbString) Then Goto Exit_Function
1825 End If
1826 If IsMissing(pvHidden) Then
1827 pvHidden = True
1828 Else
1829 If Not Utils._CheckArgument(pvHidden, 3, vbBoolean) Then Goto Exit_Function
1830 End If
1832 Dim oWindow As Object
1833 Set oWindow = _SelectWindow(pvObjectType, pvObjectName)
1834 If IsNull(oWindow.Frame) Then Goto Error_NotFound
1835 oWindow.Frame.ContainerWindow.setVisible(Not pvHidden)
1836 SetHiddenAttribute = True
1838 Exit_Function:
1839 Utils._ResetCalledSub(cstThisSub)
1840 Exit Function
1841 Error_NotFound:
1842 TraceError(TRACEFATAL, ERROBJECTNOTFOUND, Utils._CalledSub(), 0, , Array(_GetLabel(&quot;OBJECT&quot;), pvObjectName))
1843 Goto Exit_Function
1844 Error_Function:
1845 TraceError(TRACEABORT, Err, cstThisSub, Erl)
1846 GoTo Exit_Function
1847 End Function &apos; SetHiddenAttribute V1.1.0
1849 REM -----------------------------------------------------------------------------------------------------------------------
1850 Public Function SetOrderBy( _
1851 ByVal Optional pvOrder As Variant _
1852 , ByVal Optional pvControlName As Variant _
1853 ) As Boolean
1854 &apos; Sort ann open table, query, form or subform (if pvControlName present)
1856 If _ErrorHandler() Then On Local Error Goto Error_Function
1857 Const cstThisSub = &quot;SetOrderBy&quot;
1858 Utils._SetCalledSub(cstThisSub)
1859 SetOrderBy = False
1861 If IsMissing(pvOrder) Then pvOrder = &quot;&quot;
1862 If Not Utils._CheckArgument(pvOrder, 1, vbString) Then Goto Exit_Function
1863 If IsMissing(pvControlName) Then pvControlName = &quot;&quot;
1864 If Not Utils._CheckArgument(pvControlName, 1, vbString) Then Goto Exit_Function
1866 Dim sOrder As String, oWindow As Object, oDatabase As Object, oTarget As Object
1867 Set oDatabase = Application._CurrentDb()
1868 If oDatabase._DbConnect &lt;&gt; DBCONNECTBASE Then Goto Error_NotApplicable
1870 sOrder = oDatabase._ReplaceSquareBrackets(pvOrder)
1872 Set oWindow = _SelectWindow()
1873 With oWindow
1874 Select Case .WindowType
1875 Case acForm
1876 Set oTarget = _DatabaseForm(._Name, pvControlName)
1877 Case acQuery, acTable
1878 If pvControlName &lt;&gt; &quot;&quot; Then Goto Exit_Function
1879 If IsNull(.Frame.Controller.FormOperations) Then Goto Error_NotApplicable
1880 &apos; FormOperations returns &lt;Null&gt; in OpenOffice
1881 Set oTarget = .Frame.Controller.FormOperations.Cursor
1882 Case Else &apos; Ignore action
1883 Goto Exit_Function
1884 End Select
1885 End With
1887 With oTarget
1888 .Order = sOrder
1889 .reload()
1890 End With
1891 SetOrderBy = True
1893 Exit_Function:
1894 Utils._ResetCalledSub(cstThisSub)
1895 Exit Function
1896 Error_NotApplicable:
1897 TraceError(TRACEFATAL, ERRACTION, Utils._CalledSub(), 0, 1, cstThisSub)
1898 Goto Exit_Function
1899 Error_Function:
1900 TraceError(TRACEABORT, Err, cstThisSub, Erl)
1901 GoTo Exit_Function
1902 End Function &apos; SetOrderBy V1.2.0
1904 REM -----------------------------------------------------------------------------------------------------------------------
1905 Public Function ShowAllrecords() As Boolean
1906 &apos; Removes any existing filter that exists on the current table, query or form
1908 If _ErrorHandler() Then On Local Error Goto Error_Function
1909 Const cstThisSub = &quot;ShowAllRecords&quot;
1910 Utils._SetCalledSub(cstThisSub)
1911 ShowAllRecords = False
1913 Dim oWindow As Object, oDatabase As Object
1914 Set oDatabase = Application._CurrentDb()
1915 If oDatabase._DbConnect &lt;&gt; DBCONNECTBASE Then Goto Error_NotApplicable
1917 Set oWindow = _SelectWindow()
1918 Select Case oWindow.WindowType
1919 Case acForm, acQuery, acTable
1920 RunCommand(acCmdRemoveFilterSort)
1921 ShowAllrecords = True
1922 Case Else &apos; Ignore action
1923 End Select
1925 Exit_Function:
1926 Utils._ResetCalledSub(cstThisSub)
1927 Exit Function
1928 Error_NotApplicable:
1929 TraceError(TRACEFATAL, ERRACTION, Utils._CalledSub(), 0, 1, cstThisSub)
1930 Goto Exit_Function
1931 Error_Function:
1932 TraceError(TRACEABORT, Err, cstThisSub, Erl)
1933 GoTo Exit_Function
1934 End Function &apos; ShowAllrecords V1.1.0
1936 REM -----------------------------------------------------------------------------------------------------------------------
1937 REM --- PRIVATE FUNCTIONS ---
1938 REM -----------------------------------------------------------------------------------------------------------------------
1939 Private Function _CheckColumnType(pvFindWhat As Variant, vDataField As Variant) As Boolean
1940 &apos; Return true if both arguments of the same type
1941 &apos; vDataField is a ResultSet column
1943 Dim bFound As Boolean
1944 bFound = False
1945 With com.sun.star.sdbc.DataType
1946 Select Case vDataField.Type
1947 Case .DATE, .TIME, .TIMESTAMP
1948 If VarType(pvFindWhat) = vbDate Then bFound = True
1949 Case .TINYINT, .SMALLINT, .INTEGER, .BIGINT, .FLOAT, .REAL, .DOUBLE, .NUMERIC, .DECIMAL
1950 If Utils._InList(VarType(pvFindWhat), Utils._AddNumeric()) Then bFound = True
1951 Case .CHAR, .VARCHAR, .LONGVARCHAR
1952 If VarType(pvFindWhat) = vbString Then bFound = True
1953 Case Else
1954 End Select
1955 End With
1957 _CheckColumnType = bFound
1959 End Function &apos; _CheckColumnType V0.9.1
1961 REM -----------------------------------------------------------------------------------------------------------------------
1962 Private Function _DatabaseForm(psForm As String, psControl As String)
1963 &apos;Return DatabaseForm element of Form object (based on psForm which is known as a real form name)
1964 &apos;or of SubForm object (based on psControl which is checked for being a subform)
1966 Dim oForm As Object, oControl As Object, sControls() As String, iControlCount As Integer
1967 Dim bFound As Boolean, i As Integer, sName As String
1969 Set oForm = Application.Forms(psForm)
1970 If psControl &lt;&gt; &quot;&quot; Then &apos; Search subform
1971 With oForm.DatabaseForm
1972 iControlCount = .getCount()
1973 bFound = False
1974 If iControlCount &gt; 0 Then
1975 sControls() = .getElementNames()
1976 sName = UCase(Utils._Trim(psControl))
1977 For i = 0 To iControlCount - 1
1978 If UCase(sControls(i)) = sName Then
1979 bFound = True
1980 Exit For
1981 End If
1982 Next i
1983 End If
1984 End With
1985 If bFound Then sName = sControls(i) Else Goto Trace_NotFound
1986 Set oControl = oForm.Controls(sName)
1987 If oControl._SubType &lt;&gt; CTLSUBFORM Then Goto Trace_SubFormNotFound
1988 Set _DatabaseForm = oControl.Form.DatabaseForm
1989 Else
1990 Set _DatabaseForm = oForm.DatabaseForm
1991 End If
1993 Exit_Function:
1994 Exit Function
1995 Trace_NotFound:
1996 TraceError(TRACEFATAL, ERRCONTROLNOTFOUND, Utils._CalledSub(), 0, , Array(psControl, psForm))
1997 Goto Exit_Function
1998 Trace_SubFormNotFound:
1999 TraceError(TRACEFATAL, ERRSUBFORMNOTFOUND, Utils._CalledSub(), 0, , Array(psControl, psForm))
2000 Goto Exit_Function
2001 End Function &apos; _DatabaseForm V1.2.0
2003 REM -----------------------------------------------------------------------------------------------------------------------
2004 Private Sub _DispatchCommand(ByVal psCommand As String)
2005 &apos; Execute command given as argument - &quot;.uno:&quot; is presumed already present
2006 Dim oDocument As Object, oDispatcher As Object, oArgs() As new com.sun.star.beans.PropertyValue, sTargetFrameName As String
2007 Dim oResult As Variant
2008 Dim sCommand As String
2010 Set oDocument = _SelectWindow().Frame
2011 Set oDispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
2012 sTargetFrameName = &quot;&quot;
2013 oResult = oDispatcher.executeDispatch(oDocument, psCommand, sTargetFrameName, 0, oArgs())
2015 End Sub &apos; _DispatchCommand V1.3.0
2017 REM -----------------------------------------------------------------------------------------------------------------------
2018 Private Function _getTempDirectoryURL() As String
2019 &apos; Return the temporary directory defined in the OO Options (Paths)
2020 Dim sDirectory As String, oSettings As Object, oPathSettings As Object
2022 If _ErrorHandler() Then On Local Error Goto Error_Function
2024 _getTempDirectoryURL = &quot;&quot;
2025 oPathSettings = createUnoService( &quot;com.sun.star.util.PathSettings&quot; )
2026 sDirectory = oPathSettings.GetPropertyValue( &quot;Temp&quot; )
2028 _getTempDirectoryURL = sDirectory
2030 Exit_Function:
2031 Exit Function
2032 Error_Function:
2033 TraceError(&quot;ERROR&quot;, Err, &quot;_getTempDirectoryURL&quot;, Erl)
2034 _getTempDirectoryURL = &quot;&quot;
2035 Goto Exit_Function
2036 End Function &apos; _getTempDirectoryURL V0.8.5
2038 REM -----------------------------------------------------------------------------------------------------------------------
2039 Public Function _getUpperShortcut(ByVal psShortcut As String, ByVal psLastComponent As String) As String
2040 &apos; Return &quot;Forms!myForm&quot; from &quot;Forms!myForm!datField&quot; and &quot;datField&quot;
2042 If Len(psShortcut) &gt; Len(psLastComponent) Then
2043 _getUpperShortcut = Split(psShortcut, &quot;!&quot; &amp; Utils._Surround(psLastComponent))(0)
2044 Else
2045 _getUpperShortcut = psShortcut
2046 End If
2048 End Function &apos; _getUpperShortcut
2050 REM -----------------------------------------------------------------------------------------------------------------------
2051 Private Function _OpenObject(ByVal psObjectType As String _
2052 , ByVal pvObjectName As Variant _
2053 , ByVal pvView As Variant _
2054 , ByVal pvDataMode As Variant _
2055 ) As Boolean
2057 If _ErrorHandler() Then On Local Error Goto Error_Function
2059 _OpenObject = False
2060 If Not (Utils._CheckArgument(pvObjectName, 1, vbString) _
2061 And Utils._CheckArgument(pvView, 2, Utils._AddNumeric(), Array(acViewNormal, acViewPreview, acViewDesign)) _
2062 And Utils._CheckArgument(pvDataMode, 3, Utils._AddNumeric(), Array(acEdit)) _
2063 ) Then Goto Exit_Function
2064 Dim oDatabase As Object
2065 Set oDatabase = Application._CurrentDb()
2066 If oDatabase._DbConnect &lt;&gt; DBCONNECTBASE Then Goto Error_NotApplicable
2068 Dim sObjects() As String, sObjectName As String, oController As Object, oObject As Object
2069 Dim i As Integer, bFound As Boolean, lComponent As Long
2071 &apos; Check existence of object and find its exact (case-sensitive) name
2072 Select Case psObjectType
2073 Case &quot;Table&quot;
2074 sObjects = oDatabase.Connection.getTables.ElementNames()
2075 lComponent = com.sun.star.sdb.application.DatabaseObject.TABLE
2076 Case &quot;Query&quot;
2077 sObjects = oDatabase.Connection.getQueries.ElementNames()
2078 lComponent = com.sun.star.sdb.application.DatabaseObject.QUERY
2079 Case &quot;Report&quot;
2080 sObjects = oDatabase.Document.getReportDocuments.ElementNames()
2081 lComponent = com.sun.star.sdb.application.DatabaseObject.REPORT
2082 End Select
2083 bFound = False
2084 For i = 0 To UBound(sObjects)
2085 If UCase(pvObjectName) = UCase(sObjects(i)) Then
2086 sObjectName = sObjects(i)
2087 bFound = True
2088 Exit For
2089 End If
2090 Next i
2091 If Not bFound Then Goto Trace_NotFound
2093 Set oController = oDatabase.Document.CurrentController
2094 Set oObject = oController.loadComponent(lComponent, sObjectName, ( pvView = acViewDesign ))
2095 _OpenObject = True
2097 Exit_Function:
2098 Set oObject = Nothing
2099 Set oController = Nothing
2100 Exit Function
2101 Error_Function:
2102 TraceError(TRACEABORT, Err, &quot;OpenObject&quot;, Erl)
2103 GoTo Exit_Function
2104 Trace_Error:
2105 TraceError(TRACEFATAL, ERROPENOBJECT, Utils._CalledSub(), 0, , Array(_GetLabel(psObjectType), pvObjectName))
2106 Goto Exit_Function
2107 Error_NotApplicable:
2108 TraceError(TRACEFATAL, ERRACTION, Utils._CalledSub(), 0, 1)
2109 Goto Exit_Function
2110 Trace_NotFound:
2111 TraceError(TRACEFATAL, ERROBJECTNOTFOUND, Utils._CalledSub(), 0, , Array(_GetLabel(psObjectType), pvObjectName))
2112 Goto Exit_Function
2113 End Function &apos; _OpenObject V0.8.9
2115 REM -----------------------------------------------------------------------------------------------------------------------
2116 Private Function _PromptFormat() As String
2117 &apos; Return user selection in Format dialog
2119 Dim oDialog As Object, oDialogLib As Object, iOKCancel As Integer, oControl As Object
2120 Set oDialogLib = DialogLibraries
2121 If oDialogLib.hasByName(&quot;Access2BaseDev&quot;) Then
2122 If Not oDialogLib.IsLibraryLoaded(&quot;Access2BaseDev&quot;) Then oDialogLib.loadLibrary(&quot;Access2BaseDev&quot;)
2123 Set oDialog = CreateUnoDialog(DialogLibraries.Access2BaseDev.dlgFormat)
2124 Else
2125 If Not oDialogLib.IsLibraryLoaded(&quot;Access2Base&quot;) Then oDialogLib.loadLibrary(&quot;Access2Base&quot;)
2126 Set oDialog = CreateUnoDialog(DialogLibraries.Access2Base.dlgFormat)
2127 End If
2128 oDialog.Title = _GetLabel(&quot;DLGFORMAT_TITLE&quot;)
2130 Set oControl = oDialog.Model.getByName(&quot;lblFormat&quot;)
2131 oControl.Label = _GetLabel(&quot;DLGFORMAT_LBLFORMAT_LABEL&quot;)
2132 oControl.HelpText = _GetLabel(&quot;DLGFORMAT_LBLFORMAT_HELP&quot;)
2134 Set oControl = oDialog.Model.getByName(&quot;cboFormat&quot;)
2135 oControl.HelpText = _GetLabel(&quot;DLGFORMAT_LBLFORMAT_HELP&quot;)
2137 Set oControl = oDialog.Model.getByName(&quot;cmdOK&quot;)
2138 oControl.Label = _GetLabel(&quot;DLGFORMAT_CMDOK_LABEL&quot;)
2139 oControl.HelpText = _GetLabel(&quot;DLGFORMAT_CMDOK_HELP&quot;)
2141 Set oControl = oDialog.Model.getByName(&quot;cmdCancel&quot;)
2142 oControl.Label = _GetLabel(&quot;DLGFORMAT_CMDCANCEL_LABEL&quot;)
2143 oControl.HelpText = _GetLabel(&quot;DLGFORMAT_CMDCANCEL_HELP&quot;)
2145 iOKCancel = oDialog.Execute()
2146 Select Case iOKCancel
2147 Case 1 &apos; OK
2148 _PromptFormat = oDialog.Model.getByName(&quot;cboFormat&quot;).Text
2149 Case 0 &apos; Cancel
2150 _PromptFormat = &quot;&quot;
2151 Case Else
2152 End Select
2153 oDialog.Dispose()
2155 End Function &apos; _PromptFormat V0.8.5
2157 REM -----------------------------------------------------------------------------------------------------------------------
2158 Public Function _SelectWindow(Optional ByVal piWindowType As Integer, Optional ByVal psWindow As String) As Object
2159 &apos; No argument: find active window
2160 &apos; 2 arguments: find corresponding window
2161 &apos; Return a _Window object type describing the found window
2163 Dim oEnum As Object, oDesk As Object, oComp As Object, oFrame As Object, i As Integer
2164 Dim bFound As Boolean, bActive As Boolean, sName As String, iType As Integer, sDocumentType As String
2165 Dim sImplementation As String, vLocation() As Variant
2166 Dim oWindow As _Window
2168 If _ErrorHandler() Then On Local Error Goto Error_Function
2170 bActive = IsMissing(piWindowType)
2171 If IsMissing(psWindow) Then psWindow = &quot;&quot;
2172 Set oWindow.Frame = Nothing
2173 oWindow.DocumentType = &quot;&quot;
2174 If bActive Then
2175 oWindow.WindowType = acDefault
2176 oWindow._Name = &quot;&quot;
2177 Else
2178 oWindow.WindowType = piWindowType
2179 Select Case piWindowType
2180 Case acBasicIDE, acDatabaseWindow : oWindow._Name = &quot;&quot;
2181 Case Else : oWindow._Name = psWindow
2182 End Select
2183 End If
2184 iType = acDefault
2185 sDocumentType = &quot;&quot;
2187 Set oDesk = CreateUnoService(&quot;com.sun.star.frame.Desktop&quot;)
2188 Set oEnum = oDesk.Components().createEnumeration
2189 Do While oEnum.hasMoreElements
2190 Set oComp = oEnum.nextElement
2191 If Utils._hasUNOProperty(oComp, &quot;ImplementationName&quot;) Then sImplementation = oComp.ImplementationName Else sImplementation = &quot;&quot;
2192 Select Case sImplementation
2193 Case &quot;com.sun.star.comp.basic.BasicIDE&quot;
2194 Set oFrame = oComp.CurrentController.Frame
2195 iType = acBasicIDE
2196 sName = &quot;&quot;
2197 Case &quot;com.sun.star.comp.dba.ODatabaseDocument&quot;
2198 Set oFrame = oComp.CurrentController.Frame
2199 iType = acDatabaseWindow
2200 sName = &quot;&quot;
2201 Case &quot;SwXTextDocument&quot;
2202 If HasUnoInterfaces(oComp, &quot;com.sun.star.frame.XModule&quot;) Then
2203 Select Case oComp.Identifier
2204 Case &quot;com.sun.star.sdb.FormDesign&quot; &apos; Form
2205 iType = acForm
2206 Case &quot;com.sun.star.sdb.TextReportDesign&quot; &apos; Report
2207 iType = acReport
2208 Case &quot;com.sun.star.text.TextDocument&quot; &apos; Writer
2209 vLocation = Split(oComp.getLocation(), &quot;/&quot;)
2210 If UBound(vLocation) &gt;= 0 Then sName = Join(Split(vLocation(UBound(vLocation)), &quot;%20&quot;), &quot; &quot;) Else sName = &quot;&quot;
2211 iType = acDocument
2212 sDocumentType = docWriter
2213 End Select
2214 If iType = acForm Or iType = acReport Then &apos; Identify Form or Report name
2215 For i = 0 To UBound(oComp.Args())
2216 If oComp.Args(i).Name = &quot;DocumentTitle&quot; Then
2217 sName = oComp.Args(i).Value
2218 Exit For
2219 End If
2220 Next i
2221 End If
2222 Set oFrame = oComp.CurrentController.Frame
2223 End If
2224 Case &quot;org.openoffice.comp.dbu.ODatasourceBrowser&quot;
2225 Set oFrame = oComp.Frame
2226 If Not IsEmpty(oComp.Selection) Then &apos; Empty for (F4) DatasourceBrowser !!
2227 For i = 0 To UBound(oComp.Selection())
2228 If oComp.Selection(i).Name = &quot;Command&quot; Then
2229 sName = oComp.Selection(i).Value
2230 ElseIf oComp.Selection(i).Name = &quot;CommandType&quot; Then
2231 Select Case oComp.selection(i).Value
2232 Case com.sun.star.sdb.CommandType.TABLE
2233 iType = acTable
2234 Case com.sun.star.sdb.CommandType.QUERY
2235 iType = acQuery
2236 Case com.sun.star.sdb.CommandType.COMMAND
2237 iType = acQuery &apos; SQL for future use ?
2238 End Select
2239 End If
2240 Next i
2241 &apos; Else ignore
2242 End If
2243 Case &quot;org.openoffice.comp.dbu.OTableDesign&quot;, &quot;org.openoffice.comp.dbu.OQueryDesign&quot; &apos; Table or Query in Edit mode
2244 If Not bActive Then
2245 If UCase(Right(oComp.Title, Len(psWindow))) = UCase(psWindow) Then &apos; No rigorous mean found to identify Name
2246 Set oFrame = oComp.Frame
2247 Select Case sImplementation
2248 Case &quot;org.openoffice.comp.dbu.OTableDesign&quot; : iType = acTable
2249 Case &quot;org.openoffice.comp.dbu.OQueryDesign&quot; : iType = acQuery
2250 End Select
2251 sName = Right(oComp.Title, Len(psWindow))
2252 End If
2253 Else
2254 Set oFrame = Nothing
2255 End If
2256 Case &quot;org.openoffice.comp.dbu.ORelationDesign&quot;
2257 Set oFrame = oComp.Frame
2258 iType = acDiagram
2259 sName = &quot;&quot;
2260 Case &quot;com.sun.star.comp.sfx2.BackingComp&quot; &apos; Welcome screen
2261 Set oFrame = oComp.Frame
2262 iType = acWelcome
2263 sName = &quot;&quot;
2264 Case Else &apos; Other Calc, ..., whatever documents
2265 If Utils._hasUNOProperty(oComp, &quot;Location&quot;) Then
2266 vLocation = Split(oComp.getLocation(), &quot;/&quot;)
2267 If UBound(vLocation) &gt;= 0 Then sName = Join(Split(vLocation(UBound(vLocation)), &quot;%20&quot;), &quot; &quot;) Else sName = &quot;&quot;
2268 iType = acDocument
2269 If Utils._hasUNOProperty(oComp, &quot;Identifier&quot;) Then
2270 Select Case oComp.Identifier
2271 Case &quot;com.sun.star.sheet.SpreadsheetDocument&quot; : sDocumentType = docCalc
2272 Case &quot;com.sun.star.presentation.PresentationDocument&quot; : sDocumentType = docImpress
2273 Case &quot;com.sun.star.drawing.DrawingDocument&quot; : sDocumentType = docDraw
2274 Case &quot;com.sun.star.formula.FormulaProperties&quot; : sDocumentType = docMath
2275 Case Else : sDocumentType = &quot;&quot;
2276 End Select
2277 End If
2278 Set oFrame = oComp.CurrentController.Frame
2279 End If
2280 End Select
2281 If bActive And Not IsNull(oFrame) Then
2282 If oFrame.ContainerWindow.IsActive() Then
2283 bFound = True
2284 Exit Do
2285 End If
2286 ElseIf iType = piWindowType And UCase(sName) = UCase(psWindow) Then
2287 bFound = True
2288 Exit Do
2289 End If
2290 Loop
2292 If bFound Then
2293 Set oWindow.Frame = oFrame
2294 oWindow._Name = sName
2295 oWindow.WindowType = iType
2296 oWindow.DocumentType = sDocumentType
2297 Else
2298 Set oWindow.Frame = Nothing
2299 End If
2301 Exit_Function:
2302 Set _SelectWindow = oWindow
2303 Exit Function
2304 Error_Function:
2305 TraceError(TRACEABORT, Err, &quot;SelectWindow&quot;, Erl)
2306 GoTo Exit_Function
2307 End Function &apos; _SelectWindow V1.1.0
2309 REM -----------------------------------------------------------------------------------------------------------------------
2310 Private Function _SendWithAttachment( _
2311 ByVal pvRecipients() As Variant _
2312 , ByVal pvCcRecipients() As Variant _
2313 , ByVal pvBccRecipients() As Variant _
2314 , ByVal psSubject As String _
2315 , ByVal pvAttachments() As Variant _
2316 , ByVal pvBody As String _
2317 , ByVal pbEditMessage As Boolean _
2318 ) As Boolean
2320 &apos; Send message with attachments
2321 If _ErrorHandler() Then On Local Error Goto Error_Function
2322 _SendWithAttachment = False
2324 Const cstWindows = 1
2325 Const cstLinux = 4
2326 Const cstSemiColon = &quot;;&quot;
2327 Dim oServiceMail as Object, oMail As Object, oMessage As Object, vFlag As Variant
2328 Dim vCc() As Variant, i As Integer, iOS As Integer, sProduct As String, bMailProvider As Boolean
2330 &apos;OPENOFFICE &lt;= 3.6 and LIBREOFFICE have XSimple...Mail interface while OPENOFFICE &gt;= 4.0 has XSystemMailProvider interface
2331 sProduct = UCase(Utils._GetProductName())
2332 bMailProvider = ( Left(sProduct, 4) = &quot;OPEN&quot; And Left(_GetProductName(&quot;VERSION&quot;), 3) &gt;= &quot;4.0&quot; )
2334 iOS = GetGuiType()
2335 Select Case iOS
2336 Case cstLinux
2337 oServiceMail = createUnoService(&quot;com.sun.star.system.SimpleCommandMail&quot;)
2338 Case cstWindows
2339 If bMailProvider Then oServiceMail = createUnoService(&quot;com.sun.star.system.SystemMailProvider&quot;) _
2340 Else oServiceMail = createUnoService(&quot;com.sun.star.system.SimpleSystemMail&quot;)
2341 Case Else
2342 Goto Error_Mail
2343 End Select
2345 If bMailProvider Then Set oMail = oServiceMail.queryMailClient() _
2346 Else Set oMail = oServiceMail.querySimpleMailClient()
2347 If IsNull(oMail) Then Goto Error_Mail
2349 &apos;Reattribute Recipients &gt;= 2nd to ccRecipients
2350 If UBound(pvRecipients) &lt;= 0 Then
2351 If UBound(pvCcRecipients) &gt;= 0 Then vCc = pvCcRecipients
2352 Else
2353 ReDim vCc(0 To UBound(pvRecipients) - 1 + UBound(pvCcRecipients) + 1)
2354 For i = 0 To UBound(pvRecipients) - 1
2355 vCc(i) = pvRecipients(i + 1)
2356 Next i
2357 For i = UBound(pvRecipients) To UBound(vCc)
2358 vCc(i) = pvCcRecipients(i - UBound(pvRecipients))
2359 Next i
2360 End If
2362 If bMailProvider Then
2363 Set oMessage = oMail.createMailMessage()
2364 If UBound(pvRecipients) &gt;= 0 Then oMessage.Recipient = pvRecipients(0)
2365 If psSubject &lt;&gt; &quot;&quot; Then oMessage.Subject = psSubject
2366 Select Case iOS &apos; Not published differences between com.sun.star.system.SimpleCommandMail and SimpleSystemMail
2367 Case cstLinux
2368 If UBound(vCc) &gt;= 0 Then oMessage.CcRecipient = Array(Join(vCc, cstSemiColon))
2369 If UBound(pvBccRecipients) &gt;= 0 Then oMessage.BccRecipient = Array(Join(pvBccRecipients, cstSemiColon))
2370 Case cstWindows
2371 If UBound(vCc) &gt;= 0 Then oMessage.CcRecipient = vCc
2372 If UBound(pvBccRecipients) &gt;= 0 Then oMessage.BccRecipient = pvBccRecipients
2373 End Select
2374 If UBound(pvAttachments) &gt;= 0 Then oMessage.Attachement = pvAttachments
2375 If pvBody &lt;&gt; &quot;&quot; Then oMessage.Body = pvBody
2376 If pbEditMessage Then
2377 vFlag = com.sun.star.system.MailClientFlags.DEFAULTS
2378 Else
2379 vFlag = com.sun.star.system.MailClientFlags.NO_USER_INTERFACE
2380 End If
2381 oMail.sendMailMessage(oMessage, vFlag)
2382 Else
2383 Set oMessage = oMail.createSimpleMailMessage() &apos; Body NOT SUPPORTED !
2384 If UBound(pvRecipients) &gt;= 0 Then oMessage.setRecipient(pvRecipients(0))
2385 If psSubject &lt;&gt; &quot;&quot; Then oMessage.setSubject(psSubject)
2386 Select Case iOS
2387 Case cstLinux
2388 If UBound(vCc) &gt;= 0 Then oMessage.setCcRecipient(Array(Join(vCc, cstSemiColon)))
2389 If UBound(pvBccRecipients) &gt;= 0 Then oMessage.setBccRecipient(Array(Join(pvBccRecipients, cstSemiColon)))
2390 Case cstWindows
2391 If UBound(vCc) &gt;= 0 Then oMessage.setCcRecipient(vCc)
2392 If UBound(pvBccRecipients) &gt;= 0 Then oMessage.setBccRecipient(pvBccRecipients)
2393 End Select
2394 If UBound(pvAttachments) &gt;= 0 Then oMessage.setAttachement(pvAttachments)
2395 If pbEditMessage Then
2396 vFlag = com.sun.star.system.SimpleMailClientFlags.DEFAULTS
2397 Else
2398 vFlag = com.sun.star.system.SimpleMailClientFlags.NO_USER_INTERFACE
2399 End If
2400 oMail.sendSimpleMailMessage(oMessage, vFlag)
2401 End If
2403 _SendWithAttachment = True
2405 Exit_Function:
2406 Exit Function
2407 Error_Function:
2408 TraceError(TRACEABORT, Err, &quot;_SendWithAttachment&quot;, Erl)
2409 Goto Exit_Function
2410 Error_Mail:
2411 TraceError(TRACEFATAL, ERRSENDMAIL, Utils._CalledSub(), 0)
2412 Goto Exit_Function
2413 End Function &apos; _SendWithAttachment V0.9.5
2415 REM -----------------------------------------------------------------------------------------------------------------------
2416 Private Function _SendWithoutAttachment(ByVal pvTo As Variant _
2417 , ByVal pvCc As Variant _
2418 , ByVal pvBcc As Variant _
2419 , ByVal psSubject As String _
2420 , ByVal psBody As String _
2421 ) As Boolean
2422 &apos;Send simple message with mailto: syntax
2423 Dim sMailTo As String, sTo As String, sCc As String, sBcc As String, sSubject As String, sBody As String, oDispatch As Object
2424 Const cstComma = &quot;,&quot;
2425 Const cstSpace = &quot;%20&quot;
2426 Const cstCR = &quot;%0A&quot;
2428 If _ErrorHandler() Then On Local Error Goto Error_Function
2430 If UBound(pvTo) &gt;= 0 Then sTo = Trim(Join(pvTo, cstComma)) Else sTo = &quot;&quot;
2431 If UBound(pvCc) &gt;= 0 Then sCc = Trim(Join(pvCc, cstComma)) Else sCc = &quot;&quot;
2432 If UBound(pvBcc) &gt;= 0 Then sBcc = Trim(Join(pvBcc, cstComma)) Else sBcc = &quot;&quot;
2433 If psSubject &lt;&gt; &quot;&quot; Then sSubject = Join(Split(psSubject, &quot; &quot;), cstSpace) Else sSubject = &quot;&quot;
2434 If psBody &lt;&gt; &quot;&quot; Then
2435 sBody = Join(Split(psBody, Chr(13)), cstCR)
2436 sBody = Join(Split(sBody, &quot; &quot;), cstSpace)
2437 End If
2439 sMailTo = &quot;mailto:&quot; _
2440 &amp; sTo &amp; &quot;?&quot; _
2441 &amp; Iif(sCc = &quot;&quot;, &quot;&quot;, &quot;cc=&quot; &amp; sCc &amp; &quot;&amp;&quot;) _
2442 &amp; Iif(sBcc = &quot;&quot;, &quot;&quot;, &quot;bcc=&quot; &amp; sBcc &amp; &quot;&amp;&quot;) _
2443 &amp; Iif(sSubject = &quot;&quot;, &quot;&quot;, &quot;subject=&quot; &amp; sSubject &amp; &quot;&amp;&quot;) _
2444 &amp; Iif(sBody = &quot;&quot;, &quot;&quot;, &quot;body=&quot; &amp; sBody &amp; &quot;&amp;&quot;)
2445 If Right(sMailTo, 1) = &quot;&amp;&quot; Or Right(sMailTo, 1) = &quot;?&quot; Then sMailTo = Left(sMailTo, Len(sMailTo) - 1)
2447 oDispatch = createUnoService( &quot;com.sun.star.frame.DispatchHelper&quot;)
2448 oDispatch.executeDispatch(StarDesktop, sMailTo, &quot;&quot;, 0, Array())
2450 _SendWithoutAttachment = True
2452 Exit_Function:
2453 Exit Function
2454 Error_Function:
2455 TraceError(TRACEABORT, Err, &quot;_SendWithoutAttachments&quot;, Erl)
2456 _SendWithoutAttachment = False
2457 Goto Exit_Function
2458 End Function &apos; _SendWithoutAttachment V0.8.5
2460 REM -----------------------------------------------------------------------------------------------------------------------
2461 Private Sub _ShellExecute(sCommand As String)
2462 &apos; Execute shell command
2464 Dim oShell As Object
2465 Set oShell = createUnoService(&quot;com.sun.star.system.SystemShellExecute&quot;)
2466 oShell.execute(sCommand, &quot;&quot; , com.sun.star.system.SystemShellExecuteFlags.DEFAULTS)
2468 End Sub &apos; _ShellExecute V0.8.5
2469 </script:module>