VBA=IE=NTbJS自分用ノートなので、目障りだったらごめんなさい
VBAでtitleを判定し、iframeのelementをstringに変換して探します。
Option Explicit
Private Declare PtrSafe Function setforegroundwindow Lib "user32" (ByVal hwnd As LongPtr) As Long
Public flg As Boolean
Public IE As InternetExplorer
Sub frameup()
Dim gettitle As String
Dim getcstitle As String
Dim HTMLString As String
getcstitle = "Firefox"
Set IE = getcs(getcstitle)
HTMLString = getString(IE)
' Call numlockon
End Sub
Private Function getcs(gettitle As String) As InternetExplorer
Dim shl As Object
Dim nowtitle As String
Dim win As Object
Set shl = CreateObject("Shell.Application")
For Each win In shl.Windows
If TypeName(win.document) = "HTMLDocument" Then
If InStr(win.LocationURL, "Firefox") > 0 Then
Set IE = win
flg = True
Exit For
End If
End If
Next
End Function
End Function
Private Function getcim(gettitle As String) As InternetExplorer
Dim shl As Object
Dim nowtitle As String
Dim win As Object
Set shl = CreateObject("Shell.Application")
For Each win In shl.Windows
If TypeName(win.document) = "HTMLDocument" Then
getcstitle = ""
Do
getcstitle = win.document.Title
If getcstitle <> "" Then Exit Do
Loop
If InStr(win.LocationURL, "") <> 0 Then
setforegroundwindow (win.hwnd)
Set IE = win
Do While IE.Busy Or IE.redystate < READYSTATE_COMPLETE
DoEvents
Loop
End If
End If
Next
End Function
End Function
Private Function getElement(htmlDoc As HTMLDocument) As String
Dim element As Object
If InStr(htmlDoc.locaion, "Firefox") <> 0 Then
For Each element In htmlDoc.all
If UCase(element.tagName) = "INPUT" Then
If element.Name = "" And element.Value = "Firefox" Then
Application.WindowState = xlMinimized
element.Click
End If
End If
Next
End If
If InStr(htmlDoc.Location, "Google") <> 0 Then
For Each element In htmlDoc.all
Select Case UCase(element.tagName)
Case "INPUT"
End Select
Next
End If
End Function
End Function
Private Function getString(iecontents As Object, Optional depth As Long = 0) As String
Dim htmlDoc As HTMLDocument
Dim ret As String
Dim ii As Integer
On Error Resume Next
Set htmlDoc = iecontents.document
If Not htmlDoc Is Nothing Then
ret = getElement(htmlDoc)
For i = 0 To htmlDoc.frames.Length - 1
ret = getString(htmlDoc.frames(i), depth + 1)
Next
End If
Exit Function
End Function
Author And Source
この問題について(VBA=IE=NTbJS自分用ノートなので、目障りだったらごめんなさい), 我々は、より多くの情報をここで見つけました https://qiita.com/acforwev/items/74bd1cf62202d4d81b74著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .