Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long Private Const SND_ASYNC = &H1 <INI読み込み省略> Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean) If pDisp.Document Is Nothing Then Exit Sub End If ' If Not IsPicture(URL, Flags, TargetFrameName, PostData, Headers) Then ' Exit Sub ' End If Dim element As Object On Error Resume Next Set element = pDisp.Document.activeElement If Err Then Exit Sub End If On Error Resume Next If element.tagName = "A" And element.Target = "_blank" Then element.Target = "_blank" If Err Then Exit Sub End If WebBrowser1.PutProperty "targetAnchor", Array(element) Cancel = True Timer1.Interval = 55 Timer1.Enabled = True End If WebBrowser1.PutProperty "targetAnchor", Array(element) Call PlaySound("clicklink.wav", 0, SND_ASYNC) ' Cancel = False ' Timer1.Interval = 55 ' Timer1.Enabled = True End Sub Private Sub Timer1_Timer() Timer1.Enabled = False Dim v As Variant v = WebBrowser1.GetProperty("targetAnchor") WebBrowser1.PutProperty "target", Empty If IsArray(v) Then v(0).Click Erase v End If End Sub Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean) Dim f As Form2 Set f = New Form2 f.WebBrowser1.RegisterAsBrowser = True Set ppDisp = f.WebBrowser1.Object f.Show End Sub <Form_Load省略> Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.KEY Case "B_Preview" On Error Resume Next Call PlaySound("moveback.wav", 0, SND_ASYNC) WebBrowser1.GoBack If Err Then Exit Sub End If Case "B_Forward" On Error Resume Next Call PlaySound("moveforward.wav", 0, SND_ASYNC) WebBrowser1.GoForward If Err Then Exit Sub End If Case "B_refresh" Call PlaySound("refresh.wav", 0, SND_ASYNC) WebBrowser1.Refresh Case "B_HOME" On Error Resume Next Call PlaySound("returnhome.wav", 0, SND_ASYNC) WebBrowser1.Navigate (FileLocation) If Err Then Exit Sub End If End Select End Sub