Accessing Bookmarks in Edge or Chrome

Thales750

Formerly Jsanders
Local time
Today, 13:57
Joined
Dec 20, 2007
Messages
3,622
Is there a way using some kind of automation to have access to the Bookmark list without exporting or importing?
 
Both chrome and edge share a similar location. I go to:
Edge: C:\Users\USERNAME\AppData\Local\Microsoft\Edge\User Data\Default\Bookmarks
Chrome: C:\Users\USERNAME\AppData\Local\Google\Chrome\User Data\Default\Bookmarks

Each respective location contains a file without extension called Bookmarks, you can access it and get its content by simply treating it as a JSON. You can use your own methods to parse the strings, for these types of files I like to use the JsonConverter library, remember to add a reference to Microsoft Scripting Language if you're gonna use the library.
Code:
Sub getBookmarksFile()
 
    Dim FilePath As String
    Dim FileContent As String
 
    'for Chrome
    FilePath = "C:\Users\USERNAME\AppData\Local\Google\Chrome\User Data\Default\Bookmarks"
  
    'open file and store its content in a variable
    Open FilePath For Input As #1
    FileContent = Input$(LOF(1), #1)
    Close #1
  
    'parse json
    Dim jsonFile As Object
    Set jsonFile = ParseJson(FileContent)
 
    'store the bookmarks in a collection
    Dim bookmarks As New Collection
    Dim singleBookmark As Variant
    For Each singleBookmark In jsonFile("roots")("bookmark_bar")("children")
        bookmarks.Add singleBookmark
    Next
 
    'traverse collection
    Dim item As Variant
    For Each item In bookmarks
        Debug.Print item("name"), item("type"), item("url")
    Next
 
End Sub

Edit: Added code
 
Last edited:

Users who are viewing this thread

Back
Top Bottom