Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. Option Explicit
  2.  
  3. Public Sub OpenBrowserWindowByFilterAndClass( _
  4. ByRef oFilter As LDE.Filter, _
  5. ByVal sClassName As String, _
  6. ByVal sBrowserName As String, _
  7. ByVal sExplorerName As String, _
  8. ByVal bIncludeExistingFilters As Boolean _
  9. )
  10. On Error GoTo ErrorHandler
  11. Dim oClass As LDE.Class
  12. Dim oBrowser As Lime.Browser
  13. Dim oNewExplorer As Lime.Explorer
  14. Dim oNewExplorerRecords As LDE.Records
  15. Dim oNewExplorerSettings As LDE.Settings
  16. Dim PageSize As Long
  17.  
  18. ' We will open an explorer containing companies in our new browser
  19. Set oClass = Application.Database.Classes.Item(sClassName)
  20. If Not oClass Is Nothing Then
  21. PageSize = Application.Settings.Read("Application\Explorer\PageSize", 0)
  22.  
  23. Set oNewExplorerRecords = New LDE.Records
  24. Call oNewExplorerRecords.Open(oClass, , , PageSize)
  25.  
  26. ' Create the browser
  27. Set oBrowser = New Lime.Browser
  28. oBrowser.Caption = VBA.IIf(sBrowserName = "", oClass.LocalName, sBrowserName)
  29.  
  30. ' Get settings for the explorer type we will create
  31. Set oNewExplorerSettings = oBrowser.Explorers.Settings.Item(oClass.GUID)
  32.  
  33. ' Create the new explorer and assign it settings, records and name. All
  34. ' these attributes are required by the explorer
  35. Set oNewExplorer = New Lime.Explorer
  36. Set oNewExplorer.Settings = oNewExplorerSettings
  37. Set oNewExplorer.Records = oNewExplorerRecords
  38. oNewExplorer.Name = VBA.IIf(sExplorerName = "", oClass.LocalName, sExplorerName)
  39.  
  40. ' Set filter and view as well. Use the ones associated with the
  41. ' explorer's class
  42. If bIncludeExistingFilters Then
  43. Set oNewExplorer.Filters = oClass.Filters
  44. Else
  45. Set oNewExplorer.Filters = New LDE.Filters
  46. End If
  47. Call oNewExplorer.Filters.Add(oFilter)
  48. Set oNewExplorer.Views = oClass.Views
  49.  
  50. ' Make sure it's visible
  51. Call oNewExplorerSettings.Write("Visible", 1)
  52.  
  53. ' Put the explorer in search mode
  54. Call oNewExplorerSettings.Write("SearchMode", 0)
  55.  
  56. 'Set oNewExplorer.ActiveFilter = oFilter
  57. ' Add the explorer to the browser
  58. Call oBrowser.Explorers.Add(oNewExplorer)
  59.  
  60.  
  61. ' Display it
  62. Call oBrowser.show
  63.  
  64. Set oBrowser.ActiveExplorer.ActiveFilter = oFilter
  65. End If
  66. Exit Sub
  67. ErrorHandler:
  68. Call UI.ShowError("BrowserHelper.OpenBrowserWindowByFilterAndClass")
  69. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement