Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VBA: Compile error: user-defined type not defined #30

Open
stluke1840 opened this issue Jan 16, 2017 · 4 comments
Open

VBA: Compile error: user-defined type not defined #30

stluke1840 opened this issue Jan 16, 2017 · 4 comments

Comments

@stluke1840
Copy link

In the macro in the "ExcelSampleAdvanced" workbook, I am getting "Compile error: user-defined type not defined" at the line shown below. How do I correct this? Thanks

`
Option Explicit

Sub EvernoteSDKSample()

Dim EvernoteSession As New ENSessionAdvancedForCOM <<<<<<<<<COMPILE ERROR HERE

' Be sure to put your own consumer key and consumer secret here.
Call EvernoteSession.SetSharedSessionConsumerKey(SUPPRESSED, SUPPRESSED")

If EvernoteSession.SharedSession.IsAuthenticated = False Then
    Call EvernoteSession.SharedSession.AuthenticateToEvernote
End If

' Get a list of all notebooks in the user's account.
Dim myNotebooks As ENCollection
Set myNotebooks = EvernoteSession.SharedSession.ListNotebooksForCOM()

' Search for some text across all notes (i.e. personal, shared, and business).
' Change the Search Scope parameter to limit the search to only personal, shared, business - or combine flags for some combination.
Dim myNoteslist As ENCollection
Dim textToFind As String
textToFind = "some text to find"
Dim EvernoteNoteSearch As New ENNoteSearchForCOM
Set myNoteslist = EvernoteSession.SharedSession.FindNotesForCOM(EvernoteNoteSearch.NoteSearch(textToFind), Nothing, EvernoteSDK.SearchScope_All, EvernoteSDK.SortOrder_RecentlyUpdated, 500)
    
' Now load the retrieved text into a worksheet.
Dim currentRow As Integer
Dim result As ENSessionFindNotesResult
If myNoteslist.Count > 0 Then
    Dim ref As ENNoteRef
    Dim noteStore As ENNoteStoreClient
    Dim savedNoteStore As ENNoteStoreClient
    Dim edNote As edamNote
    Dim edTag As EdamTag
    Dim tagList As ENCollection
    Dim noteTag As Variant
    Dim noteTags As String
    Sheet1.Cells(1, 1) = "Note Title"
    Sheet1.Cells(1, 2) = "Notebook"
    Sheet1.Cells(1, 3) = "Tags"
    Sheet1.Cells(1, 4) = "Date Created"
    Sheet1.Cells(1, 5) = "Date Updated"
    Sheet1.Cells(1, 6) = "Note Contents"
    Sheet1.Rows(1).Font.Bold = True
    currentRow = 2
    For Each result In myNoteslist
        Set ref = result.NoteRef
        Set noteStore = EvernoteSession.SharedSession.NoteStoreForNoteRef(ref)
        Set edNote = noteStore.GetNoteForCOM(ref.GUID, True, False, False, False)
        If Not noteStore Is savedNoteStore Then
            Set tagList = noteStore.ListTagsForCOM()
            Set savedNoteStore = noteStore
        End If
        noteTags = ""
        If edNote.TagGuids.Count > 0 Then
            For Each noteTag In edNote.TagGuids
                noteTags = noteTags + tagList(noteTag).Name + ", "
            Next noteTag
            noteTags = Left(noteTags, Len(noteTags) - 2)
        End If
        Sheet1.Cells(currentRow, 1) = result.Title
        Sheet1.Cells(currentRow, 2) = result.Notebook.Name
        Sheet1.Cells(currentRow, 3) = noteTags
        Sheet1.Cells(currentRow, 4) = result.Created
        Sheet1.Cells(currentRow, 5) = result.Updated
        Sheet1.Cells(currentRow, 6) = EvernoteSession.SharedSession.NoteTextContent(edNote.Content)
        currentRow = currentRow + 1
    Next result
End If

End Sub

`

@mpnow
Copy link
Contributor

mpnow commented Jan 16, 2017

Be sure you follow the instructions in the Getting Started Guide for referencing the SDK within Excel:

In order to use the SDK with COM, be sure to add a reference to the library first. For example, in a Microsoft Word or Excel Visual Basic window, from the main menu you would select Tools > Add References..., then place a checkmark next to Evernote Cloud SDK for Windows.

@stluke1840
Copy link
Author

Thanks Phil. I have added the reference to the library, but this has made no difference. Grateful for any further advice.

@stluke1840
Copy link
Author

Just giving this a bump to see if there's a solution, as I would really like to use this macro. Thanks.

@david-navigator
Copy link

Did you solve this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants