ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Export From Bookmarks To Excel (https://www.excelbanter.com/excel-programming/394133-export-bookmarks-excel.html)

SJ Carter

Export From Bookmarks To Excel
 
Does anyone know of a program where I can export bookmarks categories,
subcategories, and URLs into corresponding columns in Excel? I found
a really great one called bookmark buddy, but it gives me a lot of
superfluous info that makes it hard to sort. I just need those three
thrings, so maybe a program that let's the user specify which info to
export?


Chip Pearson

Export From Bookmarks To Excel
 
If you're speaking of IE Bookmarks, try code like the following. You'll
need to set a reference in VBA to the "Microsoft Scripting Runtime Library"
(from the References item on the Tools menu in VBA).

Sub ListBookmarks()

Dim FSO As Scripting.FileSystemObject
Dim FolderName As String
Dim Dest As Range
Dim TopFolder As Scripting.Folder
Dim OneFile As Scripting.File
Dim TStream As Scripting.TextStream
Dim S As String
Dim Pos1 As Long
Dim Pos2 As Long
Dim URL As String

Set Dest = Worksheets("Sheet1").Range("A2")

FolderName = Environ("HOMEDRIVE") & Environ("HOMEPATH") & "\Favorites"
Set FSO = New Scripting.FileSystemObject

Set TopFolder = FSO.GetFolder(FolderName)

For Each OneFile In TopFolder.Files
Set TStream = OneFile.OpenAsTextStream(ForReading)
S = TStream.ReadAll()
Pos1 = InStr(1, S, "URL=", vbTextCompare)
If Pos1 Then
Pos2 = InStr(Pos1 + 1, S, vbNewLine, vbBinaryCompare)
If Pos2 Then
URL = Mid(S, Pos1 + 4, Pos2 - Pos1 - 4)
Dest(1, 1) = TopFolder.Name
Dest(1, 2) = OneFile.Name
Dest(1, 3) = URL
Set Dest = Dest(2, 1)
End If
End If
TStream.Close
Next OneFile

DoOneFolder FSO:=FSO, WhatFolder:=TopFolder, Dest:=Dest


End Sub

Sub DoOneFolder(FSO As Scripting.FileSystemObject, WhatFolder As
Scripting.Folder, Dest As Range)

Dim OneFile As Scripting.File
Dim OneFolder As Scripting.Folder
Dim TStream As Scripting.TextStream
Dim S As String
Dim Pos1 As Long
Dim Pos2 As Long
Dim URL As String

For Each OneFile In WhatFolder.Files
Set TStream = OneFile.OpenAsTextStream(ForReading)
S = TStream.ReadAll()
Pos1 = InStr(1, S, "URL=", vbTextCompare)
If Pos1 Then
Pos2 = InStr(Pos1 + 1, S, vbNewLine, vbBinaryCompare)
If Pos2 Then
URL = Mid(S, Pos1 + 4, Pos2 - Pos1 - 4)
Dest(1, 1) = WhatFolder.Name
Dest(1, 2) = OneFile.Name
Dest(1, 3) = URL
Set Dest = Dest(2, 1)
End If
End If
TStream.Close
Next OneFile

For Each OneFolder In WhatFolder.SubFolders
DoOneFolder FSO:=FSO, WhatFolder:=OneFolder, Dest:=Dest
Next OneFolder

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"SJ Carter" wrote in message
ps.com...
Does anyone know of a program where I can export bookmarks categories,
subcategories, and URLs into corresponding columns in Excel? I found
a really great one called bookmark buddy, but it gives me a lot of
superfluous info that makes it hard to sort. I just need those three
thrings, so maybe a program that let's the user specify which info to
export?




All times are GMT +1. The time now is 10:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com