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