Tutorial on Automating Logos4+ with ComApi in VBA

Page 1 of 2 (39 items) 1 2 Next >
This post has 38 Replies | 2 Followers

Posts 303
PJ | Forum Activity | Posted: Sat, Apr 5 2014 10:52 PM

I searched the internet on automating the ComApi in VBA/VBS with little results. The best samples is mostly in C/C++ or something. Here is something that may be of interest and help. If anyone can provide some code samples it would be appreciated.

7318.L4VBATut.zip

Posts 18577
Rosie Perera | Forum Activity | Replied: Sat, Apr 5 2014 10:57 PM

What is this bit about "This Tutorial requires LogosCom.exe"?

There is no such file in all of Logos. The executable file for Logos is called Logos.exe.

Posts 303
PJ | Forum Activity | Replied: Sun, Apr 6 2014 11:35 AM

Yes, that is true in a way. But technically, LogosCom.exe is the ComApi Type Library of Logos. When you add a Reference to the "Logos Bible Software 4 Type Library" in a VBA Project, it is actually pointing to the ActiveX (LogosCom.exe)  on your harddrive at %your Logos installation folder% \System\LogosCom.exe and not Logos.exe. Without the Type Library you can't interface with Logos.exe

If for any random reason VBA or your Development Environment of choice says "Can't create ActiveX" you will know that this file either doesn't exist, is not properly registered or you do not have the right security privalages on the file or its directory structure. It's good to know this when working with the ComApi. I encountered this error several times in VBA, VBScript, JScript and .NET 2010 Express Edition on Win 7 and 8.

I hope this explains the use of the filename LogosCom.exe

Posts 2040
Forum MVP
Randy W. Sims | Forum Activity | Replied: Sun, Apr 6 2014 11:56 AM

Nice tutorial! I like the way you put it together. I haven't looked at all the code samples in depth, just flipped through and ran a few of them. Looks very useful and very nicely put together.

Posts 6473
Forum MVP
Lynden Williams | Forum Activity | Replied: Sun, Apr 6 2014 12:06 PM

Randy, can you give a video demo?

Everything ever written in Religion and Theology formatted for Logos Bible Software.Logos Youtube Channel

Posts 2040
Forum MVP
Randy W. Sims | Forum Activity | Replied: Sun, Apr 6 2014 6:31 PM

Lynden Williams:

Randy, can you give a video demo?

Sure. Here's a real quick screencast of the some of the power point tutorial. You may have to pause to examine some of the screens in more depth.

Posts 303
PJ | Forum Activity | Replied: Fri, Apr 11 2014 1:12 AM

8037.Logos 4 COM API.zip

Programming the ComApi starts with a workable Knowledge of how Objects attach to each other. Here is my interpretation of the ObjectModel ApiVersion 3. If for any reason I made a mistake on this map, please inform me to make the corrections. If you follow the links and info on this map you should be well away on interfacing with Logos. Start at the Left Node "StartUp" and follow the map to the right. Be carefull in using recursive programming on the LogosDataTypeReference because it returns properties containing LogosDataTypeReference (See the Green nodes).

Posts 303
PJ | Forum Activity | Replied: Thu, Apr 24 2014 12:29 PM

I Paste some Code here for those that can't use or open VBA. The ClassModule have Functions that could be reused in some situations.

PASTE THIS IN A CLASSMODULE IN VBA

'Win32API - Just used for a Timer in Windows

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Dim Launcher As LogosLauncher
Dim WithEvents Logos As LogosApplication

Const ApiVersion = 3
Const ClassName As String = "CLogos"

Public Event CopyBibleVerse(Reference As String, BibleText As String)
Public Event LibraryQuery(ResourceInfo As LogosResourceInfo)
Public Event AOpenPanel(Panel As LogosPanel)

Public Enum RenderStyles
    rsSHORT = 0
    rsMEDIUM = 1
    rsLONG = 2
    rsDEFAULT = 3
End Enum
Public Enum QueryDetails
    qdIMAGE = 0
    qdTITLE = 1
    qdTYPE = 2
    qdSERIES = 3
    qdSUBJECTS = 4
    qdAUTHER = 5
    qdMYTAGS = 6
    qdRATING = 7
    qdABTEVIATEDTITLE = 8
    qdELECTRONICPUBLICATIONDATE = 9
    qdLANGUAGES = 10
    qdPUBLICATIONDATE = 11
    qdPUBLISHER = 12
    qdLASTUPDATED = 13
    qdDEVICES = 14
    qdEDITION = 15
    qdLASTACCESSED = 16
    qdMOSTUSED = 17
    qdCOMMUNITYTAGS = 18
End Enum
Sub Create(Optional CommandLineArguments As String)
    On Error GoTo ErrHandler
    Set Launcher = New LogosLauncher
    Set Logos = Nothing
    
    Stop
    Launcher.LaunchApplication CommandLineArguments
    While Logos Is Nothing
        Set Logos = Launcher.Application
    Wend
    
    If Logos.ApiVersion < ApiVersion Then _
        MsgBox "ApiVersion " & ApiVersion & _
            " Required." & vbCrLf & _
            "You have " & Logos.ApiVersion & vbCrLf & _
            "The Logos Class may not Function correctly", vbCritical, ClassName
   Exit Sub
ErrHandler:
   MsgBox Err.Number & " - " & Err.Description
   Err.Clear
End Sub
Public Function GetResourceInfo(ResourceId As String) As LogosResourceInfo
    Stop
    Set GetResourceInfo = Logos.Library.GetResourceInfo(ResourceId)
End Function
Property Get Application() As LogosApplication
    If Logos Is Nothing Then
        MsgBox "Use Create first", vbInformation, Title
        Else
        Set Application = Logos
    End If
End Property

Sub CopyBibleVerses(BibleReferences As String, Optional RenderStyle As RenderStyles = rsDEFAULT)
    Dim LDTPRC As LogosDataTypeParsedReferenceCollection
    Dim LDTPR As LogosDataTypeParsedReference
    Dim LCBVR As LogosCopyBibleVersesRequest
    
    If Logos Is Nothing Then GoTo NoLogos
    'Scan first to check if there is more than one
        Stop
        Set LDTPRC = Logos.DataTypes.GetDataType("Bible").ScanForReferences(BibleReferences)
        If LDTPRC.Count > 0 Then
            For Each LDTPR In LDTPRC
                Set LCBVR = Logos.CopyBibleVerses.CreateRequest
                LCBVR.Reference = LDTPR.Reference
                RaiseEvent CopyBibleVerse(LDTPR.Reference.Render(GetRenderStyle(RenderStyle)), Logos.CopyBibleVerses.GetText(LCBVR))
            Next
        Else
                'This will not run because all refrences are handled above
                'This is only to show how to do a CopyBibleVerseRequest
                'with one Reference another way
                Set LCBVR = Logos.CopyBibleVerses.CreateRequest
                LCBVR.Reference = Logos.DataTypes.GetDataType("Bible").ParseReference(BibleReferences)
                RaiseEvent CopyBibleVerse(LCBVR.Reference.Render(GetRenderStyle(RenderStyle)), _
                    Logos.CopyBibleVerses.GetText(LCBVR))
        End If
    Exit Sub
NoLogos:
    MsgBox "Use Create First", vbInformation, Title
ErrHandler:
    MsgBox Err.Number & " - " & Err.Description
    Err.Clear
End Sub
Private Function GetRenderStyle(rs As RenderStyles) As String
    Stop
    Select Case rs
        Case rsSHORT
            GetRenderStyle = "short"
        Case rsMEDIUM
            GetRenderStyle = "medium"
        Case rsLONG
            GetRenderStyle = "long"
        Case rsDEFAULT
            GetRenderStyle = "default"
    End Select
End Function

Sub QueryLibraryByDetails(QueryByDetail As QueryDetails, SearchString As String)
    Dim strDetail As String: getQueryDetail (querybydetails)
    Dim RIC As LogosResourceInfoCollection
    Dim RI As LogosResourceInfo
    Stop
    Set RIC = Logos.Library.GetResourcesMatchingQuery(getQueryDetail(QueryByDetail) & SearchString)
    For Each RI In RIC
        RaiseEvent LibraryQuery(RI)
    Next
End Sub
 Sub QueryLibraryByResourceType(ResourceType As String)
    Dim RIC As LogosResourceInfoCollection
    Dim RI As LogosResourceInfo
    Stop
    Set RIC = Logos.Library.GetResourcesByResourceType(ResourceType)
    For Each RI In RIC
        RaiseEvent LibraryQuery(RI)
    Next
 End Sub
Private Function getQueryDetail(qd As QueryDetails) As String
    Select Case qd
        Case qdIMAGE
            getQueryDetail = "Image:"
        Case qdTITLE
            getQueryDetail = "Title:"
        Case qdTYPE
            getQueryDetail = "Type:"
        Case qdSERIES
            getQueryDetail = "Series:"
        Case qdSUBJECTS
            getQueryDetail = "Subjects:"
        Case qdAUTHER
            getQueryDetail = "Auther:"
        Case qdMYTAGS
            getQueryDetail = "MyTags:"
        Case qdRATING
            getQueryDetail = "Rating:"
        Case qdABTEVIATEDTITLE
            getQueryDetail = "AbbreviatedTitle:"
        Case qdELECTRONICPUBLICATIONDATE
            getQueryDetail = "ElectronicPublicationDate:"
        Case qdLANGUAGES
            getQueryDetail = "Languages:"
        Case qdPUBLICATIONDATE
            getQueryDetail = "PublicationDate:"
        Case qdPUBLISHER
            getQueryDetail = "Publisher:"
        Case qdLASTUPDATED
            getQueryDetail = "LastUpdated:"
        Case qdDEVICES
            getQueryDetail = "Devices:"
        Case qdEDITION
            getQueryDetail = "Edition:"
        Case qdLASTACCESSED
            getQueryDetail = "LastAccessed:"
        Case qdMOSTUSED
            getQueryDetail = "MostUsed:"
        Case qdCOMMUNITYTAGS
            getQueryDetail = "CommunityTags:"
    End Select
End Function

Sub GetOpenPanels()
    Dim OP As LogosPanel
    For Each OP In Logos.GetOpenPanels
        RaiseEvent AOpenPanel(OP)
    Next
End Sub
Private Sub Logos_Exiting()
    Stop
End Sub

Private Sub Logos_PanelActivated(ByVal Panel As Object)
    Stop
End Sub

Private Sub Logos_PanelChanged(ByVal Panel As Object, ByVal Hint As Object)
    Stop
End Sub

Private Sub Logos_PanelClosed(ByVal Panel As Object)
    Stop
End Sub

Private Sub Logos_PanelOpened(ByVal Panel As Object)
    Stop
End Sub

Function GetNavigationRequestFromActivePanel()
    Stop
    'First I'll open the esv Bible
    'I use LoadReference to get the ref to Gen 1:1 formatted for ExecuteUri
    'You can use "bible.Gen 1:1" and there is other ways to get to this ref as well
    'This is just to show how to use LoadReference
    'and to open a Resource for the Navigation Sample
    Debug.Print Logos.DataTypes.LoadReference("bible.Gen 1:1").Save
    Logos.ExecuteUri "logosres:esv;ref=" & Logos.DataTypes.LoadReference("bible.Gen 1:1").Save
    
    Stop
    'With the following code you should keep in mind
    'There are different kinds of Panels
    
    Dim AP As LogosPanel
    Dim NR As LogosNavigationRequest
    'Take note that the following will contain info for
    'Reference Or Headword
    'This means the info inside LogosReferenceOrHeadwordCollection and LogosReferenceOrHeadword
    'may be either Reference OR Headword
    Dim HC As LogosReferenceOrHeadwordCollection
    Dim H As LogosReferenceOrHeadword
    
    Set AP = Logos.GetActivePanel
 
    If AP.DetailsKind = "Resource" Then
        Debug.Print "Now we know we can use Panel.Details"
        Debug.Print "It Return LogosResourcePanelDetails containing the ResourceId: " & AP.Details.ResourceId
        Set NR = Logos.CreateNavigationRequest
        Set HC = AP.GetCurrentReferencesAndHeadwords
        If HC.Count > 0 Then
            With NR
                .Headword = HC.Item(0).Headword
                .HeadwordLanguage = HC.Item(0).HeadwordLanguage
                .Reference = HC.Item(0).Reference
                .ResourceId = AP.Details.ResourceId
            End With
        End If
        Stop
        
        'I'll Close All in Logos so we can See the Navigation take place
        Logos.Activate
        SendKeys "%D", True
        SendKeys "Close All", True
        Sleep 2000
        SendKeys "{ENTER}", True
        

        
        Stop
        Logos.Navigate NR
        
        Stop
        'We can use the Info from the Panel to create an Uri
        Debug.Print "logosres:" & NR.ResourceId & ";ref=" & NR.Reference.Save
        'We can use that Uri to ExecuteUri
        
        Stop
        'I'll Close All in Logos so we can See the ExecuteUri take place
        Logos.Activate
        SendKeys "%D", True
        SendKeys "Close All", True
        Sleep 2000
        SendKeys "{ENTER}", True

        Stop
        Logos.ExecuteUri "logosres:" & NR.ResourceId & ";ref=" & NR.Reference.Save
    End If
    
    Stop
    'The above is a Startingpoint for a more complex way
    'to generate NavigationRequests or Uri's for different Panels
    'eg: logos4:Explorer;ref=BibleESV.Ge1.1 using logos4:(Panel.Kind obtained)
    'This way you can generate Uri's for external links from Active Panels
    'Just use your imagination
    
End Function

PASTE THIS IN A FORM IN VBA

Public WithEvents Logos As CLOgos

Private Sub Logos_AOpenPanel(Panel As Logos4Lib.LogosPanel)
    Debug.Print Panel.Title
End Sub

Private Sub Logos_CopyBibleVerse(Reference As String, BibleText As String)
    Debug.Print Reference & vbCrLf & vbTab & BibleText
End Sub

Private Sub Logos_LibraryQuery(ResourceInfo As Logos4Lib.LogosResourceInfo)
    Debug.Print ResourceInfo.Title
    Stop
End Sub

Private Sub UserForm_Initialize()
    MsgBox "This shows the complicated part of ComApi" & vbCrLf & _
        "The rest seems to be easy and straight forward"
        
    Set Logos = New CLOgos
    
    Stop
    'Create Logos
    Logos.Create
    
    Stop
    'Single Reference
    Logos.CopyBibleVerses "Joh 3:16", rsMEDIUM
    
    Stop
    'Or Multiple References
    Logos.CopyBibleVerses "Gen 1:1 AND maybe Rev 4:8 and Lev 4:3", rsLONG
     
    Stop
    'Library Query
    Logos.QueryLibraryByDetails qdTITLE, "Bible"
    
    Stop
    'Library Query By ResourceType
    Logos.QueryLibraryByResourceType "text.monograph"
    
    Stop
    'The following is to demonstrate how to get ResourceInfo
    'using ResourceId
    Dim RI As LogosResourceInfo
    Set RI = Logos.GetResourceInfo("LLS:1.0.710")
    Debug.Print RI.Title, RI.ResourceId
    'Not the ResourceId returned by ResourceInfo.ResourceId
    Set RI = Logos.GetResourceInfo("esv")
    If RI Is Nothing Then Debug.Print "Returned NOTHING"
    
    Stop
    'How to Use GetOpenPanels
    Logos.GetOpenPanels
    
    Stop
    'I'll demonstrate Application.CreateNavigationRequest and
    'Application.Navigate using GetActivePanel
    Logos.GetNavigationRequestFromActivePanel
    
End Sub

RUN THE FORM

It will Pause itself throughout the Code to show you how to use the API

Posts 3578
steve clark | Forum Activity | Replied: Thu, Apr 24 2014 4:35 PM

Pieter Kotze:
I Paste some Code here for those that can't use or open VBA. The ClassModule have Functions that could be reused in some situations.

Interesting Pieter

Especially the part of the code which inserted text into L4's command box, but it was not executed in L4.

EDIT: text from DbugPrint  4428.Pieter's dump to debug.txt

QLinks, Bibl2, LLR, Macros
Dell Insp 17-5748, i5, 1.7 GHz, 8G RAM, win 8.1

Posts 303
PJ | Forum Activity | Replied: Thu, Apr 24 2014 10:56 PM

The execution of the SendKeys could cause trouble depending on the speed of your system. Type in "Close All" in your CommandBox and take note of the time delay until the dropdown lists the Close All command. Use that time delay x 1000 in the Sleep command. That should be the delay you normally need.

        Logos.Activate
        SendKeys "%D", True
        SendKeys "Close All", True
        Sleep [TimeDelay in milliseconds]
        SendKeys "{ENTER}", True

Another reason could also be that in those 2 sec delay you probably switched focus to VBA. To make sure the command gets to Logos, insert an Actiavte command before the {ENTER}:

      Sleep [TimeDelay in milliseconds]

       Logos.Activate
       SendKeys "{ENTER}", True

Posts 303
PJ | Forum Activity | Replied: Fri, Apr 25 2014 1:53 AM

Suppose I need to read the Logos Help Manual before trying to use SendKeys.Here is a Class to SendKeys a better way.

WARNING: Do not Break into the CDoCmd.DoCmd Procedure and debug because if Logos doesn't have Focus the Keystrokes will be send to VBA. Rather just check if the SendKeys Keystrokes are correct because I did not check them all, I just wrote them quickly.


Sample: Logos.DoCmd kbs_close_all_panels

Preparations in CLogos Class:
Add to the Globals of CLogos Class: Dim KBS As CDoCmd
In CLogos Class at Sub Create(Optional CommandLineArguments As String), Add: Set KBS = New CDoCmd
In CLogos Add:

Public Sub DoCmd(eKBS As LogosKeyboardShortCuts)
    KBS.DoCmd eKBS, Logos
End Sub

A New Class CDoCmd:
Add The Following Class in VBA with the name CDoCmd

'SENDKEYS FOR LOGOS4+
Public Enum LogosKeyboardShortCuts
    kbs_activate_window_menu = 0
    kbs_add_current_location_to_Favorites = 1
    kbs_apply_visual_markup = 2
    kbs_clone_this_panel_in_a_new_tab = 3
    kbs_close_current_panel = 4
    kbs_close_panel = 5
    kbs_close_all_panels = 6
    kbs_close_program = 7
    kbs_copy = 8
    kbs_copy_ins = 9
    kbs_cut = 10
    kbs_cut_del = 11
    kbs_delete = 12
    kbs_dismiss_or_exit_drawing_mode = 13
    kbs_enter_drawing_mode_or_clear_drawing = 14
    kbs_erase_visual_markup = 15
    kbs_expand_all_timeline_groups = 16
    kbs_forces_sign_in_prompt_at_startup = 17
    kbs_go_to_Command_Box = 18
    kbs_go_to_Home_Page_from_a_floating_window = 19
    kbs_switch_home = 20
    kbs_go_to_menu_bar = 21
    kbs_go_to_next_tab = 22
    kbs_go_to_previous_tab = 23
    kbs_go_to_reference_box_of_current_resource_OR_guide = 24
    kbs_help = 25
    kbs_next = 26
    kbs_next_equivalent_resource = 27
    kbs_open_History = 28
    kbs_open_Library_in_a_floating_window = 29
    kbs_open_Search_from_a_floating_window = 30
    kbs_open_Search_panel = 31
    kbs_open_OR_close_Customize_home_page_menu = 32
    kbs_open_OR_close_File_menu = 33
    kbs_open_OR_close_Guides_menu = 34
    kbs_open_OR_close_Help_menu = 35
    kbs_open_OR_close_Home_Page = 36
    kbs_open_OR_close_Layouts = 37
    kbs_open_OR_close_Library = 38
    kbs_open_OR_close_Tools_menu = 39
    kbs_paste = 40
    kbs_paste_ins = 41
    kbs_previous = 42
    kbs_previous_equivalent_resource = 43
    kbs_print  = 44
    kbs_quick_comparison_of_the_active_verse_OR_selected_text = 45
    kbs_redo = 46
    kbs_refresh = 47
    kbs_search_for_word_OR_phrase_in_Entire_Library = 48
    kbs_search_for_word_OR_phrase_in_Top_Bibles = 49
    kbs_select_all = 50
    kbs_set_Bookmark_1 = 51
    kbs_switch_keyboard_focus_to_next_panel = 52
    kbs_switch_keyboard_focus_to_previous_panel = 53
    kbs_switch_to_next_tab = 54
    kbs_switch_to_previous_tab = 55
    kbs_undo = 56
    kbs_undo_z = 57
    kbs_zoom_in = 58
    kbs_zoom_out = 59
    kbs_zoom_to_fit = 60
    kbs_copy_location_as_URL_HTML_WIKI_RL = 61
    kbs_find_in_this_panel = 62
    kbs_read_aloud = 63
    kbs_reading_view = 64
    kbs_show_OR_hide_interlinear_pane = 65
    kbs_show_OR_hide_locator_bar = 66
    kbs_show_OR_hide_table_of_contents = 67
End Enum

Public Sub DoCmd(KBS As LogosKeyboardShortCuts, L As LogosApplication)
    L.Activate
 Select Case KBS
        Case kbs_activate_window_menu: SendKeys "% ", True
        Case kbs_add_current_location_to_Favorites: SendKeys "^d", True
        Case kbs_apply_visual_markup: SendKeys "^k", True
        Case kbs_clone_this_panel_in_a_new_tab: SendKeys "^+n", True
        Case kbs_close_current_panel: SendKeys "^{F4}", True
        Case kbs_close_panel: SendKeys "^w", True
        Case kbs_close_all_panels: SendKeys "^+w", True
        Case kbs_close_program: SendKeys "%{F4}", True
        Case kbs_copy: SendKeys "^c", True
        Case kbs_copy_ins: SendKeys "^{INS}", True
        Case kbs_cut: SendKeys "^x", True
        Case kbs_cut_del: SendKeys "+{DEL}", True
        Case kbs_delete: SendKeys "{DEL}", True
        Case kbs_dismiss_or_exit_drawing_mode: SendKeys "{Esc}", True
        Case kbs_enter_drawing_mode_or_clear_drawing: SendKeys "{F8}", True
        Case kbs_erase_visual_markup: SendKeys "^+k", True
        Case kbs_expand_all_timeline_groups: SendKeys "^e", True
        Case kbs_forces_sign_in_prompt_at_startup: SendKeys "^", True
        Case kbs_go_to_Command_Box: SendKeys "%d", True
        Case kbs_go_to_Home_Page_from_a_floating_window: SendKeys "%{HOME}", True
        Case kbs_switch_home: SendKeys "{F10}", True
        Case kbs_go_to_menu_bar: SendKeys "%", True
        Case kbs_go_to_next_tab: SendKeys "^{TAB}", True
        Case kbs_go_to_previous_tab: SendKeys "^+{TAB}", True
        Case kbs_go_to_reference_box_of_current_resource_OR_guide: SendKeys "^g", True
        Case kbs_help: SendKeys "{F1}", True
        Case kbs_next: SendKeys "%{DOWN}", True
        Case kbs_next_equivalent_resource: SendKeys "^+{RIGHT}", True
        Case kbs_open_History: SendKeys "^h", True
        Case kbs_open_Library_in_a_floating_window: SendKeys "^l", True
        Case kbs_open_Search_from_a_floating_window: SendKeys "^+s", True
        Case kbs_open_Search_panel: SendKeys "%s", True
        Case kbs_open_OR_close_Customize_home_page_menu: SendKeys "%c", True
        Case kbs_open_OR_close_File_menu: SendKeys "%f", True
        Case kbs_open_OR_close_Guides_menu: SendKeys "%g", True
        Case kbs_open_OR_close_Help_menu: SendKeys "%p", True
        Case kbs_open_OR_close_Home_Page: SendKeys "%h", True
        Case kbs_open_OR_close_Layouts: SendKeys "%a", True
        Case kbs_open_OR_close_Library: SendKeys "%l", True
        Case kbs_open_OR_close_Tools_menu: SendKeys "%t", True
        Case kbs_paste: SendKeys "^v", True
        Case kbs_paste_ins: SendKeys "+{INS}", True
        Case kbs_previous: SendKeys "%{UP}", True
        Case kbs_previous_equivalent_resource: SendKeys "^+{LEFT}", True
        Case kbs_print : SendKeys "^p", True
        Case kbs_quick_comparison_of_the_active_verse_OR_selected_text: SendKeys "{F7}", True
        Case kbs_redo: SendKeys "^y", True
        Case kbs_refresh: SendKeys "{F5}", True
        Case kbs_search_for_word_OR_phrase_in_Entire_Library: SendKeys "^+{ENTER}", True
        Case kbs_search_for_word_OR_phrase_in_Top_Bibles: SendKeys "^{ENTER}", True
        Case kbs_select_all: SendKeys "^a", True
        Case kbs_set_Bookmark_1: SendKeys "^+1", True
        Case kbs_switch_keyboard_focus_to_next_panel: SendKeys "^{F6}", True
        Case kbs_switch_keyboard_focus_to_previous_panel: SendKeys "^+{F6}", True
        Case kbs_switch_to_next_tab: SendKeys "^{PGDN}", True
        Case kbs_switch_to_previous_tab: SendKeys "^{PGUP}", True
        Case kbs_undo: SendKeys "%{BACKSPACE}", True
        Case kbs_undo_z: SendKeys "^z", True
        Case kbs_zoom_in: SendKeys "^=", True
        Case kbs_zoom_out: SendKeys "^-", True
        Case kbs_zoom_to_fit: SendKeys "^0", True
        Case kbs_copy_location_as_URL_HTML_WIKI_RL: SendKeys "^%c", True
        Case kbs_find_in_this_panel:  SendKeys "^f", True
        Case kbs_read_aloud: SendKeys "^r", True
        Case kbs_reading_view: SendKeys "{F11}", True
        Case kbs_show_OR_hide_interlinear_pane: SendKeys "^+r", True
        Case kbs_show_OR_hide_locator_bar: SendKeys "^+l", True
        Case kbs_show_OR_hide_table_of_contents: SendKeys "^+c", True
    End Select
End Sub

Back in CLogos:
In Class CLogos, replace:
        Logos.Activate
        SendKeys "%D", True
        SendKeys "Close All", True
        Sleep 2000
        SendKeys "{ENTER}", True
With:
    DoCmd kbs_close_all_panels

How to Use:
Now from the Form you can use: Logos.DoCmd kbs_close_all_panels
You can use this class in any app with the following Syntax:
    DoCmd LogosKeyBoardShortCuts, LogosApplication

Posts 1499
Forum MVP
Fr Devin Roza | Forum Activity | Replied: Fri, Apr 25 2014 2:55 AM

This is incredibly useful - thanks for sharing! I have been wondering if such a thing was possible with Logos. 

I have been unable to make this work, however - I imagine because I am using Verbum??

I have the LogosCom.EXE file, and the reference appears correctly in VBA to the file. However, whenever the code gets to:

oLauncher.LaunchApplication

it returns error 13, "Type Mismatch". Then if I go into Debug mode, and run through the code line by line, at oLauncher.LaunchApplication it gives the error: "Method 'LaunchApplication' of object 'ILogosLauncher' failed" (Run-time error -2147417851 (80010105). 

This happens regardless if Verbum is open or not. Any ideas?

Posts 303
PJ | Forum Activity | Replied: Fri, Apr 25 2014 6:29 AM

I could only advise you on how I would start debugging if I ran into this error. The following is by no means expert advice or even technically correct.

I used Logos Bible Software 5.2a SR-1 (5.2.1.0081) with Api Version 3  (5.2.1.81). I do not know if the ComApi also updates automatically.

  1. My first guess would be Version incompatibility between Logos Bible Software and the ComApi because of the fact that it accured on oLauncher.LaunchApplication. Because Nothing is being Set on the VBA side the TypeMismatch could come from the external source being Referenced.
  2. Second guess would be that there are 2 LogosCom.exe versions on your system. One being registered in windows and the other being Referenced in VBA.

I would try to Create the Launcher with late binding first (I did not test this, just wrote it here):

Sub Test()

    Dim oLauncher    'DO NOT USE As LogosLauncher HERE

    on error goto ErrHandler

    Set oLauncher = CreateObject("LogosBibleSoftware.Launcher") 'The version independent ProgID

    oLauncher.LaunchApplication

    Beep 'If we get here it works"

    stop 

Exit Sub

ErrHandler:

    Beep: Beep

    stop

    Debug.Print Err.Number & " - " & Err.Description

End Sub

If this worked, search if there is another LogosCom.exe file on your system.

Hope this directs you into a meaningfull debug session.

Posts 3578
steve clark | Forum Activity | Replied: Fri, Apr 25 2014 8:28 AM

Fr Devin Roza:
This happens regardless if Verbum is open or not. Any ideas?

When i copied Pieter's code (a few posts above), i had to:

  1. Setup a Reference to Logos' API  (click an image below to view full size)

       

  2. Had to name the Class to what Pieter had named his Class

Here is my Excel file with Pieter's stuff (class renamed) 3443.Book1.zip
(had to zip the Excel file because the forum editor doesn't allow files with macros, so you will need to unzip the file.

More steps

  • When you open the Excel file, it will give you a warning that it contains Macros, so click on the gold bar & allow it to run the macros.
  • Another thought, i would try opening Verbum before running the macro  (see you already tried this)
  • On the worksheet you will see a single button, click it once to start Pieter's macro.

QLinks, Bibl2, LLR, Macros
Dell Insp 17-5748, i5, 1.7 GHz, 8G RAM, win 8.1

Posts 3578
steve clark | Forum Activity | Replied: Fri, Apr 25 2014 9:18 AM

Pieter Kotze:
Suppose I need to read the Logos Help Manual before trying to use SendKeys.Here is a Class to SendKeys a better way.

It is working now, i had to allow more time since i am running on a slow computer (see my PC specs below in my signature).

Thanks Pieter for your hard work!

btw, how do you see this api being used inside of an Office app? i am curious.

It seems you can use it to copy Bible verses, open a panel inside of L4, get book names in your library. Guess i am not looking outside the box to see how i would use this info inside of Excel for instance, except to get a list of my L4 library. To copy Bible verses into Excel seems like a lot of work to use the api. Figure you already have ideas on what you are trying to do with the api inside your Office apps. So i would be curious how you see using this.

QLinks, Bibl2, LLR, Macros
Dell Insp 17-5748, i5, 1.7 GHz, 8G RAM, win 8.1

Posts 1499
Forum MVP
Fr Devin Roza | Forum Activity | Replied: Fri, Apr 25 2014 9:27 AM

Pieter Kotze:

I would try to Create the Launcher with late binding first (I did not test this, just wrote it here):

Sub Test()

    Dim oLauncher    'DO NOT USE As LogosLauncher HERE

    on error goto ErrHandler

    Set oLauncher = CreateObject("LogosBibleSoftware.Launcher") 'The version independent ProgID

    oLauncher.LaunchApplication

    Beep 'If we get here it works"

    stop 

Exit Sub

ErrHandler:

    Beep: Beep

    stop

    Debug.Print Err.Number & " - " & Err.Description

End Sub

If this worked, search if there is another LogosCom.exe file on your system.

Hope this directs you into a meaningfull debug session.

Thanks for the help. The code seemingly completes correctly Set oLauncher = CreateObject("LogosBibleSoftware.Launcher"). But then, on oLauncher.LaunchApplication it errors out.

The Debug.Print returns:

-2147417851 - Automation error
The server threw an exception.

Posts 1499
Forum MVP
Fr Devin Roza | Forum Activity | Replied: Fri, Apr 25 2014 9:36 AM

steve clark:

Fr Devin Roza:
This happens regardless if Verbum is open or not. Any ideas?

When i copied Pieter's code (a few posts above), i had to:

  1. Setup a Reference to Logos' API  (click an image below to view full size)

       

  2. Had to name the Class to what Pieter had named his Class

Here is my Excel file with Pieter's stuff (class renamed) 3443.Book1.zip
(had to zip the Excel file because the forum editor doesn't allow files with macros, so you will need to unzip the file.

More steps

  • When you open the Excel file, it will give you a warning that it contains Macros, so click on the gold bar & allow it to run the macros.
  • Another thought, i would try opening Verbum before running the macro  (see you already tried this)
  • On the worksheet you will see a single button, click it once to start Pieter's macro.

Thanks for the help. Here is my Reference window. Everything seems to be correct as far as I can tell:

When I click on the button in your Excel Sheet I get the following pop-up:

The code then runs to the "Stop". I then run through the code with F8 line by line.

Debug.Print outputs "-- Created -- Logos class"

The code moves on to the Create subroutine. Then, on the line of code "Launcher.LaunchApplication CommandLineArguments" it errors out. Here is the message:

Maybe someone from Logos could run a test on a Verbum system to confirm if it is a Verbum bug?

Posts 3578
steve clark | Forum Activity | Replied: Fri, Apr 25 2014 9:43 AM

Fr Devin Roza:
The code then runs to the "Stop". I then run through the code with F8 line by line.

Sounds like you have done everything right...

you might try using F5 instead (which will run to the next breakpoint), perhaps the stepping line by line is interrupting something timing-wise (just a guess).

EDIT:

Fr Devin Roza:
Debug.Print outputs "-- Created -- Logos class"

i added a few extra Debug.Print statements (like this) to help me recognize when things were being added to the debug window (some steps added a lot of stuff).

QLinks, Bibl2, LLR, Macros
Dell Insp 17-5748, i5, 1.7 GHz, 8G RAM, win 8.1

Posts 1499
Forum MVP
Fr Devin Roza | Forum Activity | Replied: Fri, Apr 25 2014 10:05 AM

steve clark:

you might try using F5 instead (which will run to the next breakpoint), perhaps the stepping line by line is interrupting something timing-wise (just a guess).

Errors out at the same moment, although the error box is slightly more detailed (same error number, though):

Posts 3578
steve clark | Forum Activity | Replied: Fri, Apr 25 2014 10:12 AM

Fr Devin Roza:
Errors out at the same moment, although the error box is slightly more detailed (same error number, though):

This does sound like a Verbum issue.

But to cover all basis, below are images of how i have Excel Options set (File->Options)
[click images for full-size viewing]

             

A long time ago, i had to fiddle with the Macros permission; i may have fiddled with a few other permissions too. So the above settings are what i have now.

QLinks, Bibl2, LLR, Macros
Dell Insp 17-5748, i5, 1.7 GHz, 8G RAM, win 8.1

Page 1 of 2 (39 items) 1 2 Next > | RSS