私が作成しているマクロは、Excel スプレッドシートから名前を取得し、Internet Explorer を開き、オンライン ディレクトリを検索します。ディレクトリを検索した後、管理者の名前を含む Java フォームを表示します。マネージャー名に手動でタブ移動し、右クリックしてショートカットをコピーし、それをスプレッドシートに戻すことができます。ただし、一貫したタブ移動とショートカットのコピーに問題があります。
- IE ウィンドウにフォーカスを戻す簡単な方法はありますか?
- 手動でクリックせずにショートカットをコピーするにはどうすればよいですか?
コード:
Sub Macro1()
'
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")
ie.Visible = True
ie.navigate "****url****"
While ie.busy
DoEvents
Wend
ie.document.getElementById("SSOID").Value = "Z19516732"
ie.document.getElementById("Advanced").Checked = False
ie.document.all("Search").Click
'this loop is to slow the macro as the java form is filled from the search
For i = 1 To 400000000
i = i + 1
Next i
'ie.Object.Activate
ie.document.getElementById("Advanced").Checked = False
ie.document.getElementById("SSOID").Focus
Application.SendKeys "{TAB 6}" ', True
'bring up the control menu/right click
Application.SendKeys "+{F10}"
'copy shortcut is 8 items down on the list
Application.SendKeys "{DOWN}"
Application.SendKeys "{DOWN}"
Application.SendKeys "{DOWN}"
Application.SendKeys "{DOWN}"
Application.SendKeys "{DOWN}"
Application.SendKeys "{DOWN}"
Application.SendKeys "{DOWN}"
Application.SendKeys "{DOWN}"
'enter was not working so the shortcut for the menu is 't'
'SendKeys "{ENTER}"
Application.SendKeys "{t}"
Windows("Book21").Activate
Range("A1").Select
ActiveSheet.Paste
End Sub