'
'******** AKIRA55.COM ******* https://akira55.com/Bookmark/
'
Sub Bookmark01() 'EXCELシートにIEのブックマーク(お気に入り)一覧を作成して管理する。
Dim Exp_Shell, Win_Shell, IE_temp As Object
Dim ws01 As Worksheet
Dim IE_Title, IE_Url, Temp01 As String
Dim Dic, I, lRow As Long
Dim Flag As Boolean
Dim Keys
Set Dic = CreateObject("Scripting.Dictionary")
Set Exp_Shell = CreateObject("shell.application") '現在開いているIEページをExp_Shellへ収納します。
Set ws01 = Worksheets("ブックマーク管理") '取得したタイトル名を転記するシート名を指定します。
lRow = ws01.Cells(Rows.Count, "A").End(xlUp).Row 'シート「ブックマーク管理」の最終行を取得します。
I = lRow + 1
For Each Win_Shell In Exp_Shell.Windows '開いているIEページを全て繰り返します。
IE_Title = "" '取得するIEタイトルをクリアーします。
On Error Resume Next 'タイトル名が取得できない場合のエラーを回避します。
IE_Title = Win_Shell.Document.Title '取得したタイトル名をIE_Titleへ代入します。
IE_Url = Win_Shell.LocationURL '取得したURLをIE_URLへ代入します。
On Error GoTo 0
If IE_Title <> "" Then 'IEのタイトル名を取得したら「ブックマーク管理」シートに転記します。
With ws01
Cells(I, "A") = Date '「ブックマーク管理」シートのA列に【No】を代入します。
Cells(I, "B") = IE_Title '「ブックマーク管理」シートのB列に【タイトル名】を代入します。
.Hyperlinks.Add anchor:=Range("C" & I), Address:=IE_Url '「ブックマーク管理」シートのC列に【URL】を代入します。
Cells(I, "D") = "〇"
End With
I = I + 1 '行を1段加算します。
End If
Next Win_Shell
lRow = ws01.Cells(Rows.Count, "A").End(xlUp).Row 'シート「ブックマーク管理」の最終行を取得します。
For I = lRow To 2 Step -1
Temp01 = ws01.Cells(I, "B")
If Not Dic.Exists(Temp01) Then
Dic.Add Temp01, Temp01 '重複しないタイトル名を登録します。(辞書登録)
Else
ws01.Rows(I).Delete '重複しているタイトル名の行を削除します。
End If
Next I
With Range("A1").CurrentRegion 'A1から始まる表を自動的に選択
.Borders.LineStyle = xlContinuous '囲線を選択
.Borders.ColorIndex = 1 '色を選択
.Borders.Weight = xlThin '太字を選択
End With
End Sub
’
'
'******** AKIRA55.COM ******* https://akira55.com/Bookmark/
'
Sub Bookmark02() 'EXCELシートにブックマーク管理している表示対象のWebページを表示する
Dim IEWeb As InternetExplorer
Dim ws01 As Worksheet
Dim I, L, lRow As Long
Dim S_bookmark As String
Set IEWeb = CreateObject("InternetExplorer.application")
Set ws01 = Worksheets("ブックマーク管理") '取得したタイトル名を転記するシート名を指定します。
IEWeb.Visible = True 'InternetExplorerを表示する。
L = 0
lRow = ws01.Cells(Rows.Count, "A").End(xlUp).Row 'シート「ブックマーク管理」の最終行を取得します。
For I = 2 To lRow
If ws01.Cells(I, "D") = "〇" Then '表示対象の"〇"URLを表示させる。
S_bookmark = ws01.Cells(I, "C") 'C列のURLを取得する。
If L = 0 Then
IEWeb.Navigate2 S_bookmark ''InternetExplorerで指定したURLのページを表示します。(1件目は通常表示)
L = 1
Else
IEWeb.Navigate2 S_bookmark, &H800 ''InternetExplorerで指定したURLのページを表示します。(2件目以降はタブ表示)
End If
End If
Next I
End Sub
'